Index: extensions/browser/api/web_request/web_request_event_details.cc |
diff --git a/extensions/browser/api/web_request/web_request_event_details.cc b/extensions/browser/api/web_request/web_request_event_details.cc |
index d7a3e10c82713c857339ceb6b1323cfbc1f87b62..4d6b4cf6ec1216b63de963237febefb71663e510 100644 |
--- a/extensions/browser/api/web_request/web_request_event_details.cc |
+++ b/extensions/browser/api/web_request/web_request_event_details.cc |
@@ -9,6 +9,7 @@ |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/render_frame_host.h" |
#include "content/public/browser/resource_request_info.h" |
+#include "content/public/browser/websocket_handshake_request_info.h" |
#include "content/public/common/child_process_host.h" |
#include "extensions/browser/api/web_request/upload_data_presenter.h" |
#include "extensions/browser/api/web_request/web_request_api_constants.h" |
@@ -32,6 +33,8 @@ WebRequestEventDetails::WebRequestEventDetails(const net::URLRequest* request, |
: extra_info_spec_(extra_info_spec), |
render_process_id_(content::ChildProcessHost::kInvalidUniqueID), |
render_frame_id_(MSG_ROUTING_NONE) { |
+ DCHECK(request); |
+ |
content::ResourceType resource_type = content::RESOURCE_TYPE_LAST_TYPE; |
const content::ResourceRequestInfo* info = |
content::ResourceRequestInfo::ForRequest(request); |
@@ -40,10 +43,21 @@ WebRequestEventDetails::WebRequestEventDetails(const net::URLRequest* request, |
render_frame_id_ = info->GetRenderFrameID(); |
resource_type = info->GetResourceType(); |
} else { |
- // Fallback for requests that are not allocated by a ResourceDispatcherHost, |
- // such as the TemplateURLFetcher. |
- content::ResourceRequestInfo::GetRenderFrameForRequest( |
- request, &render_process_id_, &render_frame_id_); |
+ // TODO(pkalinnikov): Consider embedding WebSocketHandshakeRequestInfo into |
+ // UrlRequestUserData. |
+ if (request->url().SchemeIsWSOrWSS()) { |
Devlin
2017/02/14 01:21:38
Can we put this if on line 45?
if (info) {
...
}
pkalinnikov
2017/02/14 13:49:51
Done.
|
+ const content::WebSocketHandshakeRequestInfo* ws_info = |
+ content::WebSocketHandshakeRequestInfo::ForRequest(request); |
+ if (ws_info) { |
+ render_process_id_ = ws_info->GetChildId(); |
+ render_frame_id_ = ws_info->GetRenderFrameId(); |
+ } |
+ } else { |
+ // Fallback for requests that are not allocated by a |
+ // ResourceDispatcherHost, such as the TemplateURLFetcher. |
+ content::ResourceRequestInfo::GetRenderFrameForRequest( |
+ request, &render_process_id_, &render_frame_id_); |
+ } |
} |
dict_.SetString(keys::kMethodKey, request->method()); |