Chromium Code Reviews| 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 a0ba5ba505c207df9d5f599d06ff0b3465d11123..f4d43a383489a97da90496a6a970a515297d0495 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()) { |
|
mmenke
2016/11/16 18:20:39
Why would WebRequestEventDetails be created for re
mmenke
2016/11/16 18:21:27
Oh, WebRequest...was thinking WebSocketRequest...S
|
| + 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()); |