• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_BROWSER_NET_SERVICE_BROWSER_URLREQUEST_IMPL_H_
6 #define CEF_LIBCEF_BROWSER_NET_SERVICE_BROWSER_URLREQUEST_IMPL_H_
7 
8 #include <memory>
9 
10 #include "include/cef_urlrequest.h"
11 
12 #include "third_party/abseil-cpp/absl/types/optional.h"
13 
14 namespace content {
15 struct GlobalRequestID;
16 }
17 
18 class CefBrowserURLRequest : public CefURLRequest {
19  public:
20   class Context;
21 
22   // TODO(network): After the old network code path is deleted move the
23   // CefURLRequestClient::GetAuthCredentials callback to the context thread and
24   // return just the CefBrowserURLRequest object here. The *Client object can
25   // then be retrieved by calling GetClient() from the required thread.
26   using RequestInfo = std::pair<CefRefPtr<CefBrowserURLRequest>,
27                                 CefRefPtr<CefURLRequestClient>>;
28 
29   // Retrieve the request objects, if any, associated with |request_id|.
30   static absl::optional<RequestInfo> FromRequestID(int32_t request_id);
31   static absl::optional<RequestInfo> FromRequestID(
32       const content::GlobalRequestID& request_id);
33 
34   // If |frame| is nullptr requests can still be intercepted but no
35   // browser/frame will be associated with them.
36   CefBrowserURLRequest(CefRefPtr<CefFrame> frame,
37                        CefRefPtr<CefRequest> request,
38                        CefRefPtr<CefURLRequestClient> client,
39                        CefRefPtr<CefRequestContext> request_context);
40   ~CefBrowserURLRequest() override;
41 
42   bool Start();
43 
44   // CefURLRequest methods.
45   CefRefPtr<CefRequest> GetRequest() override;
46   CefRefPtr<CefURLRequestClient> GetClient() override;
47   Status GetRequestStatus() override;
48   ErrorCode GetRequestError() override;
49   CefRefPtr<CefResponse> GetResponse() override;
50   bool ResponseWasCached() override;
51   void Cancel() override;
52 
53  private:
54   bool VerifyContext();
55 
56   std::unique_ptr<Context> context_;
57 
58   IMPLEMENT_REFCOUNTING(CefBrowserURLRequest);
59 };
60 
61 #endif  // CEF_LIBCEF_BROWSER_NET_SERVICE_BROWSER_URLREQUEST_IMPL_H_
62