Chromium Code Reviews| 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/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/public/browser/global_request_id.h" | 10 #include "content/public/browser/global_request_id.h" |
| 11 #include "content/public/common/previews_state.h" | 11 #include "content/public/common/previews_state.h" |
| 12 #include "content/public/common/resource_type.h" | 12 #include "content/public/common/resource_type.h" |
| 13 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" | 13 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" |
| 14 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 14 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 15 #include "ui/base/page_transition_types.h" | 15 #include "ui/base/page_transition_types.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 class URLRequest; | 18 class URLRequest; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 class NavigationUIData; | 22 class NavigationUIData; |
| 23 class RenderFrameHost; | |
| 23 class ResourceContext; | 24 class ResourceContext; |
| 24 class WebContents; | 25 class WebContents; |
| 25 | 26 |
| 26 // Each URLRequest allocated by the ResourceDispatcherHost has a | 27 // Each URLRequest allocated by the ResourceDispatcherHost has a |
| 27 // ResourceRequestInfo instance associated with it. | 28 // ResourceRequestInfo instance associated with it. |
| 28 class ResourceRequestInfo { | 29 class ResourceRequestInfo { |
| 29 public: | 30 public: |
| 30 // Returns the ResourceRequestInfo associated with the given URLRequest. | 31 // Returns the ResourceRequestInfo associated with the given URLRequest. |
| 31 CONTENT_EXPORT static const ResourceRequestInfo* ForRequest( | 32 CONTENT_EXPORT static const ResourceRequestInfo* ForRequest( |
| 32 const net::URLRequest* request); | 33 const net::URLRequest* request); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 const net::URLRequest* request); | 67 const net::URLRequest* request); |
| 67 | 68 |
| 68 // A callback that returns a pointer to a WebContents. The callback can | 69 // A callback that returns a pointer to a WebContents. The callback can |
| 69 // always be used, but it may return nullptr: if the info used to | 70 // always be used, but it may return nullptr: if the info used to |
| 70 // instantiate the callback can no longer be used to return a WebContents, | 71 // instantiate the callback can no longer be used to return a WebContents, |
| 71 // nullptr will be returned instead. | 72 // nullptr will be returned instead. |
| 72 // The callback should only run on the UI thread and it should always be | 73 // The callback should only run on the UI thread and it should always be |
| 73 // non-null. | 74 // non-null. |
| 74 using WebContentsGetter = base::Callback<WebContents*(void)>; | 75 using WebContentsGetter = base::Callback<WebContents*(void)>; |
| 75 | 76 |
| 77 // A callback that returns a pointer to a RenderFrameHost. The callback can | |
| 78 // always be used, but it may return nullptr: if the info used to | |
| 79 // instantiate the callback can no longer be used to return a | |
| 80 // RenderFrameHost, nullptr will be returned instead. | |
| 81 // The callback should only run on the UI thread and it should always be | |
| 82 // non-null. | |
| 83 using RenderFrameHostGetter = base::Callback<RenderFrameHost*(void)>; | |
| 84 | |
| 76 // Returns a callback that returns a pointer to the WebContents this request | 85 // Returns a callback that returns a pointer to the WebContents this request |
| 77 // is associated with, or nullptr if it no longer exists or the request is | 86 // is associated with, or nullptr if it no longer exists or the request is |
| 78 // not associated with a WebContents. The callback should only run on the UI | 87 // not associated with a WebContents. The callback should only run on the UI |
| 79 // thread. | 88 // thread. |
| 80 // Note: Not all resource requests will be owned by a WebContents. For | 89 // Note: Not all resource requests will be owned by a WebContents. For |
| 81 // example, requests made by a ServiceWorker. | 90 // example, requests made by a ServiceWorker. |
| 82 virtual WebContentsGetter GetWebContentsGetterForRequest() const = 0; | 91 virtual WebContentsGetter GetWebContentsGetterForRequest() const = 0; |
| 83 | 92 |
| 93 // Returns a callback that returns a pointer to the RenderFrameHost this | |
| 94 // request is associated with, or nullptry if it no longer exists or the | |
| 95 // request is not associated with a RenderFrameHost. This callback should | |
| 96 // only be run on the UI thread. | |
| 97 // Note: Not all resource requests will be owned by a RenderFrameHost. For | |
| 98 // example, requests made by a ServiceWorker. | |
|
clamy
2017/04/14 13:56:09
Looking at the implementation, this comment is sim
Charlie Harrison
2017/04/14 14:02:25
I think returning nullptr here for navigations is
jkarlin
2017/04/14 17:50:20
I spoke with clamy@ and csharrison@. We agreed on
| |
| 99 virtual RenderFrameHostGetter GetRenderFrameHostGetterForRequest() const = 0; | |
| 100 | |
| 84 // Returns the associated ResourceContext. | 101 // Returns the associated ResourceContext. |
| 85 virtual ResourceContext* GetContext() const = 0; | 102 virtual ResourceContext* GetContext() const = 0; |
| 86 | 103 |
| 87 // The child process unique ID of the requestor. | 104 // The child process unique ID of the requestor. |
| 88 // To get a WebContents, use GetWebContentsGetterForRequest instead. | 105 // To get a WebContents, use GetWebContentsGetterForRequest instead. |
| 89 virtual int GetChildID() const = 0; | 106 virtual int GetChildID() const = 0; |
| 90 | 107 |
| 91 // The IPC route identifier for this request (this identifies the RenderView | 108 // The IPC route identifier for this request (this identifies the RenderView |
| 92 // or like-thing in the renderer that the request gets routed to). | 109 // or like-thing in the renderer that the request gets routed to). |
| 93 // To get a WebContents, use GetWebContentsGetterForRequest instead. | 110 // To get a WebContents, use GetWebContentsGetterForRequest instead. |
| 94 // Don't use this method for new code, as RenderViews are going away. | 111 // Don't use this method for new code, as RenderViews are going away. |
| 95 virtual int GetRouteID() const = 0; | 112 virtual int GetRouteID() const = 0; |
| 96 | 113 |
| 97 // The globally unique identifier for this request. | 114 // The globally unique identifier for this request. |
| 98 virtual GlobalRequestID GetGlobalRequestID() const = 0; | 115 virtual GlobalRequestID GetGlobalRequestID() const = 0; |
| 99 | 116 |
| 100 // The pid of the originating process, if the request is sent on behalf of a | 117 // The pid of the originating process, if the request is sent on behalf of a |
| 101 // another process. Otherwise it is 0. | 118 // another process. Otherwise it is 0. |
| 102 virtual int GetOriginPID() const = 0; | 119 virtual int GetOriginPID() const = 0; |
| 103 | 120 |
| 104 // Returns the FrameTreeNode ID for this frame. This ID is browser-global and | 121 // Returns the FrameTreeNode ID for this frame. This ID is browser-global and |
| 105 // uniquely identifies a frame that hosts content. | 122 // uniquely identifies a frame that hosts content. |
| 123 // Note: Returns -1 for all requests except PlzNavigate requests. | |
| 124 // TODO(jkarlin): Set the id for all requests from frames. | |
| 106 virtual int GetFrameTreeNodeId() const = 0; | 125 virtual int GetFrameTreeNodeId() const = 0; |
| 107 | 126 |
| 108 // The IPC route identifier of the RenderFrame. | 127 // The IPC route identifier of the RenderFrame. |
| 109 // To get a WebContents, use GetWebContentsGetterForRequest instead. | 128 // To get a WebContents, use GetWebContentsGetterForRequest instead. |
| 110 // TODO(jam): once all navigation and resource requests are sent between | 129 // TODO(jam): once all navigation and resource requests are sent between |
| 111 // frames and RenderView/RenderViewHost aren't involved we can remove this and | 130 // frames and RenderView/RenderViewHost aren't involved we can remove this and |
| 112 // just use GetRouteID above. | 131 // just use GetRouteID above. |
| 113 virtual int GetRenderFrameID() const = 0; | 132 virtual int GetRenderFrameID() const = 0; |
| 114 | 133 |
| 115 // True if GetRenderFrameID() represents a main frame in the RenderView. | 134 // True if GetRenderFrameID() represents a main frame in the RenderView. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 // UI thread at the beginning of navigation. | 186 // UI thread at the beginning of navigation. |
| 168 virtual NavigationUIData* GetNavigationUIData() const = 0; | 187 virtual NavigationUIData* GetNavigationUIData() const = 0; |
| 169 | 188 |
| 170 protected: | 189 protected: |
| 171 virtual ~ResourceRequestInfo() {} | 190 virtual ~ResourceRequestInfo() {} |
| 172 }; | 191 }; |
| 173 | 192 |
| 174 } // namespace content | 193 } // namespace content |
| 175 | 194 |
| 176 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ | 195 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ |
| OLD | NEW |