OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ |
6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ | 6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback_forward.h" |
9 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
10 #include "content/public/common/resource_type.h" | 11 #include "content/public/common/resource_type.h" |
11 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" | 12 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" |
12 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 13 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
13 #include "ui/base/page_transition_types.h" | 14 #include "ui/base/page_transition_types.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 class URLRequest; | 17 class URLRequest; |
17 } | 18 } |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 class ResourceContext; | 21 class ResourceContext; |
| 22 class WebContents; |
21 | 23 |
22 // Each URLRequest allocated by the ResourceDispatcherHost has a | 24 // Each URLRequest allocated by the ResourceDispatcherHost has a |
23 // ResourceRequestInfo instance associated with it. | 25 // ResourceRequestInfo instance associated with it. |
24 class ResourceRequestInfo { | 26 class ResourceRequestInfo { |
25 public: | 27 public: |
26 // Returns the ResourceRequestInfo associated with the given URLRequest. | 28 // Returns the ResourceRequestInfo associated with the given URLRequest. |
27 CONTENT_EXPORT static const ResourceRequestInfo* ForRequest( | 29 CONTENT_EXPORT static const ResourceRequestInfo* ForRequest( |
28 const net::URLRequest* request); | 30 const net::URLRequest* request); |
29 | 31 |
30 // Allocates a new, dummy ResourceRequestInfo and associates it with the | 32 // Allocates a new, dummy ResourceRequestInfo and associates it with the |
(...skipping 13 matching lines...) Expand all Loading... |
44 | 46 |
45 // Returns the associated RenderFrame for a given process. Returns false, if | 47 // Returns the associated RenderFrame for a given process. Returns false, if |
46 // there is no associated RenderFrame. This method does not rely on the | 48 // there is no associated RenderFrame. This method does not rely on the |
47 // request being allocated by the ResourceDispatcherHost, but works for all | 49 // request being allocated by the ResourceDispatcherHost, but works for all |
48 // URLRequests that are associated with a RenderFrame. | 50 // URLRequests that are associated with a RenderFrame. |
49 CONTENT_EXPORT static bool GetRenderFrameForRequest( | 51 CONTENT_EXPORT static bool GetRenderFrameForRequest( |
50 const net::URLRequest* request, | 52 const net::URLRequest* request, |
51 int* render_process_id, | 53 int* render_process_id, |
52 int* render_frame_id); | 54 int* render_frame_id); |
53 | 55 |
| 56 // A callback that returns a pointer to a WebContents. The callback can |
| 57 // always be used, but it may return nullptr: if the info used to |
| 58 // instantiate the callback can no longer be used to return a WebContents, |
| 59 // nullptr will be returned instead. |
| 60 // The callback should only run on the UI thread and it should always be |
| 61 // non-null. |
| 62 using WebContentsGetter = base::Callback<WebContents*(void)>; |
| 63 |
| 64 // Returns a callback that returns a pointer to the WebContents this request |
| 65 // is associated with, or nullptr if it no longer exists or the request is |
| 66 // not associated with a WebContents. The callback should only run on the UI |
| 67 // thread. |
| 68 // Note: Not all resource requests will be owned by a WebContents. For |
| 69 // example, requests made by a ServiceWorker. |
| 70 virtual WebContentsGetter GetWebContentsGetterForRequest() const = 0; |
| 71 |
54 // Returns the associated ResourceContext. | 72 // Returns the associated ResourceContext. |
55 virtual ResourceContext* GetContext() const = 0; | 73 virtual ResourceContext* GetContext() const = 0; |
56 | 74 |
57 // The child process unique ID of the requestor. | 75 // The child process unique ID of the requestor. |
| 76 // To get a WebContents, use GetWebContentsGetterForRequest instead. |
58 virtual int GetChildID() const = 0; | 77 virtual int GetChildID() const = 0; |
59 | 78 |
60 // The IPC route identifier for this request (this identifies the RenderView | 79 // The IPC route identifier for this request (this identifies the RenderView |
61 // or like-thing in the renderer that the request gets routed to). | 80 // or like-thing in the renderer that the request gets routed to). |
| 81 // To get a WebContents, use GetWebContentsGetterForRequest instead. |
62 virtual int GetRouteID() const = 0; | 82 virtual int GetRouteID() const = 0; |
63 | 83 |
64 // The pid of the originating process, if the request is sent on behalf of a | 84 // The pid of the originating process, if the request is sent on behalf of a |
65 // another process. Otherwise it is 0. | 85 // another process. Otherwise it is 0. |
66 virtual int GetOriginPID() const = 0; | 86 virtual int GetOriginPID() const = 0; |
67 | 87 |
68 // The IPC route identifier of the RenderFrame. | 88 // The IPC route identifier of the RenderFrame. |
| 89 // To get a WebContents, use GetWebContentsGetterForRequest instead. |
69 // TODO(jam): once all navigation and resource requests are sent between | 90 // TODO(jam): once all navigation and resource requests are sent between |
70 // frames and RenderView/RenderViewHost aren't involved we can remove this and | 91 // frames and RenderView/RenderViewHost aren't involved we can remove this and |
71 // just use GetRouteID above. | 92 // just use GetRouteID above. |
72 virtual int GetRenderFrameID() const = 0; | 93 virtual int GetRenderFrameID() const = 0; |
73 | 94 |
74 // True if GetRenderFrameID() represents a main frame in the RenderView. | 95 // True if GetRenderFrameID() represents a main frame in the RenderView. |
75 virtual bool IsMainFrame() const = 0; | 96 virtual bool IsMainFrame() const = 0; |
76 | 97 |
77 // True if GetParentRenderFrameID() represents a main frame in the RenderView. | 98 // True if GetParentRenderFrameID() represents a main frame in the RenderView. |
78 virtual bool ParentIsMainFrame() const = 0; | 99 virtual bool ParentIsMainFrame() const = 0; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Whether this request if using Lo-Fi mode. | 146 // Whether this request if using Lo-Fi mode. |
126 virtual bool IsUsingLoFi() const = 0; | 147 virtual bool IsUsingLoFi() const = 0; |
127 | 148 |
128 protected: | 149 protected: |
129 virtual ~ResourceRequestInfo() {} | 150 virtual ~ResourceRequestInfo() {} |
130 }; | 151 }; |
131 | 152 |
132 } // namespace content | 153 } // namespace content |
133 | 154 |
134 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ | 155 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ |
OLD | NEW |