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" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 const net::URLRequest* request); | 66 const net::URLRequest* request); |
67 | 67 |
68 // A callback that returns a pointer to a WebContents. The callback can | 68 // 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 | 69 // 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, | 70 // instantiate the callback can no longer be used to return a WebContents, |
71 // nullptr will be returned instead. | 71 // nullptr will be returned instead. |
72 // The callback should only run on the UI thread and it should always be | 72 // The callback should only run on the UI thread and it should always be |
73 // non-null. | 73 // non-null. |
74 using WebContentsGetter = base::Callback<WebContents*(void)>; | 74 using WebContentsGetter = base::Callback<WebContents*(void)>; |
75 | 75 |
| 76 // A callback that returns a frame tree node id . The callback can always |
| 77 // be used, but it may return -1 if no id is found. The callback should only |
| 78 // run on the UI thread. |
| 79 using FrameTreeNodeIdGetter = base::Callback<int(void)>; |
| 80 |
76 // Returns a callback that returns a pointer to the WebContents this request | 81 // 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 | 82 // 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 | 83 // not associated with a WebContents. The callback should only run on the UI |
79 // thread. | 84 // thread. |
80 // Note: Not all resource requests will be owned by a WebContents. For | 85 // Note: Not all resource requests will be owned by a WebContents. For |
81 // example, requests made by a ServiceWorker. | 86 // example, requests made by a ServiceWorker. |
82 virtual WebContentsGetter GetWebContentsGetterForRequest() const = 0; | 87 virtual WebContentsGetter GetWebContentsGetterForRequest() const = 0; |
83 | 88 |
| 89 // Returns a callback that returns an int with the frame tree node id |
| 90 // associated with this request, or -1 if it no longer exists. This |
| 91 // callback should only be run on the UI thread. |
| 92 // Note: Not all resource requests will be associated with a frame. For |
| 93 // example, requests made by a ServiceWorker. |
| 94 virtual FrameTreeNodeIdGetter GetFrameTreeNodeIdGetterForRequest() const = 0; |
| 95 |
84 // Returns the associated ResourceContext. | 96 // Returns the associated ResourceContext. |
85 virtual ResourceContext* GetContext() const = 0; | 97 virtual ResourceContext* GetContext() const = 0; |
86 | 98 |
87 // The child process unique ID of the requestor. | 99 // The child process unique ID of the requestor. |
88 // To get a WebContents, use GetWebContentsGetterForRequest instead. | 100 // To get a WebContents, use GetWebContentsGetterForRequest instead. |
89 virtual int GetChildID() const = 0; | 101 virtual int GetChildID() const = 0; |
90 | 102 |
91 // The IPC route identifier for this request (this identifies the RenderView | 103 // The IPC route identifier for this request (this identifies the RenderView |
92 // or like-thing in the renderer that the request gets routed to). | 104 // or like-thing in the renderer that the request gets routed to). |
93 // To get a WebContents, use GetWebContentsGetterForRequest instead. | 105 // To get a WebContents, use GetWebContentsGetterForRequest instead. |
94 // Don't use this method for new code, as RenderViews are going away. | 106 // Don't use this method for new code, as RenderViews are going away. |
95 virtual int GetRouteID() const = 0; | 107 virtual int GetRouteID() const = 0; |
96 | 108 |
97 // The globally unique identifier for this request. | 109 // The globally unique identifier for this request. |
98 virtual GlobalRequestID GetGlobalRequestID() const = 0; | 110 virtual GlobalRequestID GetGlobalRequestID() const = 0; |
99 | 111 |
100 // The pid of the originating process, if the request is sent on behalf of a | 112 // The pid of the originating process, if the request is sent on behalf of a |
101 // another process. Otherwise it is 0. | 113 // another process. Otherwise it is 0. |
102 virtual int GetOriginPID() const = 0; | 114 virtual int GetOriginPID() const = 0; |
103 | 115 |
104 // Returns the FrameTreeNode ID for this frame. This ID is browser-global and | 116 // Returns the FrameTreeNode ID for this frame. This ID is browser-global and |
105 // uniquely identifies a frame that hosts content. | 117 // uniquely identifies a frame that hosts content. |
| 118 // Note: Returns -1 for all requests except PlzNavigate requests. |
106 virtual int GetFrameTreeNodeId() const = 0; | 119 virtual int GetFrameTreeNodeId() const = 0; |
107 | 120 |
108 // The IPC route identifier of the RenderFrame. | 121 // The IPC route identifier of the RenderFrame. |
109 // To get a WebContents, use GetWebContentsGetterForRequest instead. | 122 // To get a WebContents, use GetWebContentsGetterForRequest instead. |
110 // TODO(jam): once all navigation and resource requests are sent between | 123 // TODO(jam): once all navigation and resource requests are sent between |
111 // frames and RenderView/RenderViewHost aren't involved we can remove this and | 124 // frames and RenderView/RenderViewHost aren't involved we can remove this and |
112 // just use GetRouteID above. | 125 // just use GetRouteID above. |
113 virtual int GetRenderFrameID() const = 0; | 126 virtual int GetRenderFrameID() const = 0; |
114 | 127 |
115 // True if GetRenderFrameID() represents a main frame in the RenderView. | 128 // 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. | 180 // UI thread at the beginning of navigation. |
168 virtual NavigationUIData* GetNavigationUIData() const = 0; | 181 virtual NavigationUIData* GetNavigationUIData() const = 0; |
169 | 182 |
170 protected: | 183 protected: |
171 virtual ~ResourceRequestInfo() {} | 184 virtual ~ResourceRequestInfo() {} |
172 }; | 185 }; |
173 | 186 |
174 } // namespace content | 187 } // namespace content |
175 | 188 |
176 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ | 189 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ |
OLD | NEW |