OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/net/chrome_extensions_network_delegate.h" | 5 #include "chrome/browser/net/chrome_extensions_network_delegate.h" |
6 | 6 |
7 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
8 | 8 |
9 #if defined(ENABLE_EXTENSIONS) | 9 #if defined(ENABLE_EXTENSIONS) |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 using content::ResourceRequestInfo; | 23 using content::ResourceRequestInfo; |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 enum RequestStatus { REQUEST_STARTED, REQUEST_DONE }; | 27 enum RequestStatus { REQUEST_STARTED, REQUEST_DONE }; |
28 | 28 |
29 // Notifies the extensions::ProcessManager that a request has started or stopped | 29 // Notifies the extensions::ProcessManager that a request has started or stopped |
30 // for a particular RenderFrame. | 30 // for a particular RenderFrame. |
31 void NotifyEPMRequestStatus(RequestStatus status, | 31 void NotifyEPMRequestStatus(RequestStatus status, |
32 void* profile_id, | 32 void* profile_id, |
| 33 uint64 request_id, |
33 int process_id, | 34 int process_id, |
34 int render_frame_id) { | 35 int render_frame_id) { |
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
36 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 37 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
37 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 38 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
38 return; | 39 return; |
39 | 40 |
40 extensions::ProcessManager* process_manager = | 41 extensions::ProcessManager* process_manager = |
41 extensions::ProcessManager::Get(profile); | 42 extensions::ProcessManager::Get(profile); |
42 DCHECK(process_manager); | 43 DCHECK(process_manager); |
43 | 44 |
44 // Will be NULL if the request was not issued on behalf of a renderer (e.g. a | 45 // Will be NULL if the request was not issued on behalf of a renderer (e.g. a |
45 // system-level request). | 46 // system-level request). |
46 content::RenderFrameHost* render_frame_host = | 47 content::RenderFrameHost* render_frame_host = |
47 content::RenderFrameHost::FromID(process_id, render_frame_id); | 48 content::RenderFrameHost::FromID(process_id, render_frame_id); |
48 if (render_frame_host) { | 49 if (render_frame_host) { |
49 if (status == REQUEST_STARTED) { | 50 if (status == REQUEST_STARTED) { |
50 process_manager->OnNetworkRequestStarted(render_frame_host); | 51 process_manager->OnNetworkRequestStarted(render_frame_host, request_id); |
51 } else if (status == REQUEST_DONE) { | 52 } else if (status == REQUEST_DONE) { |
52 process_manager->OnNetworkRequestDone(render_frame_host); | 53 process_manager->OnNetworkRequestDone(render_frame_host, request_id); |
53 } else { | 54 } else { |
54 NOTREACHED(); | 55 NOTREACHED(); |
55 } | 56 } |
56 } | 57 } |
57 } | 58 } |
58 | 59 |
59 void ForwardRequestStatus( | 60 void ForwardRequestStatus( |
60 RequestStatus status, net::URLRequest* request, void* profile_id) { | 61 RequestStatus status, net::URLRequest* request, void* profile_id) { |
61 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 62 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
62 if (!info) | 63 if (!info) |
63 return; | 64 return; |
64 | 65 |
65 if (status == REQUEST_STARTED && request->url_chain().size() > 1) { | 66 if (status == REQUEST_STARTED && request->url_chain().size() > 1) { |
66 // It's a redirect, this request has already been counted. | 67 // It's a redirect, this request has already been counted. |
67 return; | 68 return; |
68 } | 69 } |
69 | 70 |
70 int process_id, render_frame_id; | 71 int process_id, render_frame_id; |
71 if (info->GetAssociatedRenderFrame(&process_id, &render_frame_id)) { | 72 if (info->GetAssociatedRenderFrame(&process_id, &render_frame_id)) { |
72 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 73 BrowserThread::PostTask( |
73 base::Bind(&NotifyEPMRequestStatus, | 74 BrowserThread::UI, FROM_HERE, |
74 status, profile_id, process_id, render_frame_id)); | 75 base::Bind(&NotifyEPMRequestStatus, status, profile_id, |
| 76 request->identifier(), process_id, render_frame_id)); |
75 } | 77 } |
76 } | 78 } |
77 | 79 |
78 class ChromeExtensionsNetworkDelegateImpl | 80 class ChromeExtensionsNetworkDelegateImpl |
79 : public ChromeExtensionsNetworkDelegate { | 81 : public ChromeExtensionsNetworkDelegate { |
80 public: | 82 public: |
81 explicit ChromeExtensionsNetworkDelegateImpl( | 83 explicit ChromeExtensionsNetworkDelegateImpl( |
82 extensions::EventRouterForwarder* event_router); | 84 extensions::EventRouterForwarder* event_router); |
83 ~ChromeExtensionsNetworkDelegateImpl() override; | 85 ~ChromeExtensionsNetworkDelegateImpl() override; |
84 | 86 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 345 } |
344 | 346 |
345 net::NetworkDelegate::AuthRequiredResponse | 347 net::NetworkDelegate::AuthRequiredResponse |
346 ChromeExtensionsNetworkDelegate::OnAuthRequired( | 348 ChromeExtensionsNetworkDelegate::OnAuthRequired( |
347 net::URLRequest* request, | 349 net::URLRequest* request, |
348 const net::AuthChallengeInfo& auth_info, | 350 const net::AuthChallengeInfo& auth_info, |
349 const AuthCallback& callback, | 351 const AuthCallback& callback, |
350 net::AuthCredentials* credentials) { | 352 net::AuthCredentials* credentials) { |
351 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 353 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
352 } | 354 } |
OLD | NEW |