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/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 | |
|
asanka
2015/11/25 19:33:02
Nit: stray ':'
clamy
2015/11/27 13:29:06
Done.
| |
| 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 WebContentsGetterOnUIThread = base::Callback<WebContents*(void)>; | |
|
asanka
2015/11/25 19:33:02
Nit: WebContentsGetter should also be sufficient s
clamy
2015/11/27 13:29:06
Done.
| |
| 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 WebContentsGetterOnUIThread GetWebContentsGetterForRequest() | |
|
asanka
2015/11/25 19:33:02
Nit: GetWebContentsGetter is also sufficient.
clamy
2015/11/27 13:29:06
Done.
| |
| 71 const = 0; | |
| 72 | |
| 54 // Returns the associated ResourceContext. | 73 // Returns the associated ResourceContext. |
| 55 virtual ResourceContext* GetContext() const = 0; | 74 virtual ResourceContext* GetContext() const = 0; |
| 56 | 75 |
| 57 // The child process unique ID of the requestor. | 76 // The child process unique ID of the requestor. |
| 77 // Use GetWebContentsGetterForRequest instead. | |
|
asanka
2015/11/25 19:33:02
Nit: These comments assume that the respective met
clamy
2015/11/27 13:29:06
Done.
| |
| 58 virtual int GetChildID() const = 0; | 78 virtual int GetChildID() const = 0; |
| 59 | 79 |
| 60 // The IPC route identifier for this request (this identifies the RenderView | 80 // The IPC route identifier for this request (this identifies the RenderView |
| 61 // or like-thing in the renderer that the request gets routed to). | 81 // or like-thing in the renderer that the request gets routed to). |
| 82 // Use GetWebContentsGetterForRequest instead. | |
| 62 virtual int GetRouteID() const = 0; | 83 virtual int GetRouteID() const = 0; |
| 63 | 84 |
| 64 // The pid of the originating process, if the request is sent on behalf of a | 85 // The pid of the originating process, if the request is sent on behalf of a |
| 65 // another process. Otherwise it is 0. | 86 // another process. Otherwise it is 0. |
| 66 virtual int GetOriginPID() const = 0; | 87 virtual int GetOriginPID() const = 0; |
| 67 | 88 |
| 68 // The IPC route identifier of the RenderFrame. | 89 // The IPC route identifier of the RenderFrame. |
| 90 // Use GetWebContentsGetterForRequest instead. | |
| 69 // TODO(jam): once all navigation and resource requests are sent between | 91 // TODO(jam): once all navigation and resource requests are sent between |
| 70 // frames and RenderView/RenderViewHost aren't involved we can remove this and | 92 // frames and RenderView/RenderViewHost aren't involved we can remove this and |
| 71 // just use GetRouteID above. | 93 // just use GetRouteID above. |
| 72 virtual int GetRenderFrameID() const = 0; | 94 virtual int GetRenderFrameID() const = 0; |
| 73 | 95 |
| 74 // True if GetRenderFrameID() represents a main frame in the RenderView. | 96 // True if GetRenderFrameID() represents a main frame in the RenderView. |
| 75 virtual bool IsMainFrame() const = 0; | 97 virtual bool IsMainFrame() const = 0; |
| 76 | 98 |
| 77 // True if GetParentRenderFrameID() represents a main frame in the RenderView. | 99 // True if GetParentRenderFrameID() represents a main frame in the RenderView. |
| 78 virtual bool ParentIsMainFrame() const = 0; | 100 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. | 147 // Whether this request if using Lo-Fi mode. |
| 126 virtual bool IsUsingLoFi() const = 0; | 148 virtual bool IsUsingLoFi() const = 0; |
| 127 | 149 |
| 128 protected: | 150 protected: |
| 129 virtual ~ResourceRequestInfo() {} | 151 virtual ~ResourceRequestInfo() {} |
| 130 }; | 152 }; |
| 131 | 153 |
| 132 } // namespace content | 154 } // namespace content |
| 133 | 155 |
| 134 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ | 156 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_REQUEST_INFO_H_ |
| OLD | NEW |