Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: chrome/browser/renderer_host/resource_dispatcher_host.h

Issue 16546: Blocking resource request for hidden page when interstitial showing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This is the browser side of the resource dispatcher, it receives requests 5 // This is the browser side of the resource dispatcher, it receives requests
6 // from the RenderProcessHosts, and dispatches them to URLRequests. It then 6 // from the RenderProcessHosts, and dispatches them to URLRequests. It then
7 // fowards the messages from the URLRequests back to the correct process for 7 // fowards the messages from the URLRequests back to the correct process for
8 // handling. 8 // handling.
9 // 9 //
10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
11 11
12 #ifndef CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ 12 #ifndef CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_
13 #define CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ 13 #define CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_
14 14
15 #include <map> 15 #include <map>
16 #include <string> 16 #include <string>
17 #include <vector>
17 18
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/observer_list.h" 20 #include "base/observer_list.h"
20 #include "base/ref_counted.h" 21 #include "base/ref_counted.h"
21 #include "base/timer.h" 22 #include "base/timer.h"
22 #include "chrome/browser/renderer_host/resource_handler.h" 23 #include "chrome/browser/renderer_host/resource_handler.h"
23 #include "chrome/common/filter_policy.h" 24 #include "chrome/common/filter_policy.h"
24 #include "chrome/common/ipc_message.h" 25 #include "chrome/common/ipc_message.h"
25 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
26 #include "webkit/glue/resource_type.h" 27 #include "webkit/glue/resource_type.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // 196 //
196 void BeginRequest(Receiver* receiver, 197 void BeginRequest(Receiver* receiver,
197 HANDLE render_process_handle, 198 HANDLE render_process_handle,
198 int render_process_host_id, 199 int render_process_host_id,
199 int render_view_id, 200 int render_view_id,
200 int request_id, 201 int request_id,
201 const ViewHostMsg_Resource_Request& request, 202 const ViewHostMsg_Resource_Request& request,
202 URLRequestContext* request_context, 203 URLRequestContext* request_context,
203 IPC::Message* sync_result); 204 IPC::Message* sync_result);
204 205
205 // Initiate a download from the browser process (as opposed to a resource 206 // Initiates a download from the browser process (as opposed to a resource
206 // request from the renderer). 207 // request from the renderer).
207 void BeginDownload(const GURL& url, 208 void BeginDownload(const GURL& url,
208 const GURL& referrer, 209 const GURL& referrer,
209 int render_process_host_id, 210 int render_process_host_id,
210 int render_view_id, 211 int render_view_id,
211 URLRequestContext* request_context); 212 URLRequestContext* request_context);
212 213
213 // Initiate a save file from the browser process (as opposed to a resource 214 // Initiates a save file from the browser process (as opposed to a resource
214 // request from the renderer). 215 // request from the renderer).
215 void BeginSaveFile(const GURL& url, 216 void BeginSaveFile(const GURL& url,
216 const GURL& referrer, 217 const GURL& referrer,
217 int render_process_host_id, 218 int render_process_host_id,
218 int render_view_id, 219 int render_view_id,
219 URLRequestContext* request_context); 220 URLRequestContext* request_context);
220 221
221 // Cancels the given request if it still exists. We ignore cancels from the 222 // Cancels the given request if it still exists. We ignore cancels from the
222 // renderer in the event of a download. 223 // renderer in the event of a download.
223 void CancelRequest(int render_process_host_id, 224 void CancelRequest(int render_process_host_id,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return r; 295 return r;
295 } 296 }
296 297
297 static const ExtraRequestInfo* ExtraInfoForRequest(const URLRequest* request) { 298 static const ExtraRequestInfo* ExtraInfoForRequest(const URLRequest* request) {
298 const ExtraRequestInfo* r = 299 const ExtraRequestInfo* r =
299 static_cast<const ExtraRequestInfo*>(request->user_data()); 300 static_cast<const ExtraRequestInfo*>(request->user_data());
300 DLOG_IF(WARNING, !r) << "Request doesn't seem to have our data"; 301 DLOG_IF(WARNING, !r) << "Request doesn't seem to have our data";
301 return r; 302 return r;
302 } 303 }
303 304
304 // Add an observer. The observer will be called on the IO thread. To 305 // Adds an observer. The observer will be called on the IO thread. To
305 // observe resource events on the UI thread, subscribe to the 306 // observe resource events on the UI thread, subscribe to the
306 // NOTIFY_RESOURCE_* notifications of the notification service. 307 // NOTIFY_RESOURCE_* notifications of the notification service.
307 void AddObserver(Observer* obs); 308 void AddObserver(Observer* obs);
308 309
309 // Remove an observer. 310 // Removes an observer.
310 void RemoveObserver(Observer* obs); 311 void RemoveObserver(Observer* obs);
311 312
312 // Retrieves a URLRequest. Must be called from the IO thread. 313 // Retrieves a URLRequest. Must be called from the IO thread.
313 URLRequest* GetURLRequest(GlobalRequestID request_id) const; 314 URLRequest* GetURLRequest(GlobalRequestID request_id) const;
314 315
315 // A test to determining whether a given request should be forwarded to the 316 // A test to determining whether a given request should be forwarded to the
316 // download thread. 317 // download thread.
317 bool ShouldDownload(const std::string& mime_type, 318 bool ShouldDownload(const std::string& mime_type,
318 const std::string& content_disposition); 319 const std::string& content_disposition);
319 320
320 // Notify our observers that a request has been cancelled. 321 // Notifies our observers that a request has been cancelled.
321 void NotifyResponseCompleted(URLRequest* request, int render_process_host_id); 322 void NotifyResponseCompleted(URLRequest* request, int render_process_host_id);
322 323
323 void RemovePendingRequest(int render_process_host_id, int request_id); 324 void RemovePendingRequest(int render_process_host_id, int request_id);
324 325
326 // Causes all new requests for the render view identified by
327 // |render_process_host_id| and |render_view_id| to be blocked (not being
328 // started) until ResumeBlockedRequestsForRenderView or
329 // CancelBlockedRequestsForRenderView is called.
330 void BlockRequestsForRenderView(int render_process_host_id,
331 int render_view_id);
332
333 // Resumes any blocked request for the specified RenderView.
334 void ResumeBlockedRequestsForRenderView(int render_process_host_id,
335 int render_view_id);
336
337 // Cancels any blocked request for the specified RenderView.
338 void CancelBlockedRequestsForRenderView(int render_process_host_id,
339 int render_view_id);
340
325 private: 341 private:
342 FRIEND_TEST(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies);
326 class ShutdownTask; 343 class ShutdownTask;
327 344
328 friend class ShutdownTask; 345 friend class ShutdownTask;
329 346
347 struct BlockedRequest {
348 BlockedRequest(URLRequest* url_request, bool mixed_content)
349 : url_request(url_request),
350 mixed_content(mixed_content) {
351 }
352 URLRequest* url_request;
353 bool mixed_content;
354 };
355
330 // A shutdown helper that runs on the IO thread. 356 // A shutdown helper that runs on the IO thread.
331 void OnShutdown(); 357 void OnShutdown();
332 358
333 // Returns true if the request is paused. 359 // Returns true if the request is paused.
334 bool PauseRequestIfNeeded(ExtraRequestInfo* info); 360 bool PauseRequestIfNeeded(ExtraRequestInfo* info);
335 361
336 // Resumes the given request by calling OnResponseStarted or OnReadCompleted. 362 // Resumes the given request by calling OnResponseStarted or OnReadCompleted.
337 void ResumeRequest(const GlobalRequestID& request_id); 363 void ResumeRequest(const GlobalRequestID& request_id);
338 364
339 // Reads data from the response using our internal buffer as async IO. 365 // Reads data from the response using our internal buffer as async IO.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 int render_process_host_id, 415 int render_process_host_id,
390 int tab_contents_id, 416 int tab_contents_id,
391 const GURL& url, 417 const GURL& url,
392 ResourceType::Type resource_type, 418 ResourceType::Type resource_type,
393 ResourceHandler* handler); 419 ResourceHandler* handler);
394 420
395 void UpdateLoadStates(); 421 void UpdateLoadStates();
396 422
397 void MaybeUpdateUploadProgress(ExtraRequestInfo *info, URLRequest *request); 423 void MaybeUpdateUploadProgress(ExtraRequestInfo *info, URLRequest *request);
398 424
425 // Resumes or cancels (if |cancel_requests| is true) any blocked requests.
426 void ProcessBlockedRequestsForRenderView(int render_process_host_id,
427 int render_view_id,
428 bool cancel_requests);
429
399 PendingRequestList pending_requests_; 430 PendingRequestList pending_requests_;
400 431
401 // We cache the UI message loop so we can create new UI-related objects on it. 432 // We cache the UI message loop so we can create new UI-related objects on it.
402 MessageLoop* ui_loop_; 433 MessageLoop* ui_loop_;
403 434
404 // We cache the IO loop to ensure that GetURLRequest is only called from the 435 // We cache the IO loop to ensure that GetURLRequest is only called from the
405 // IO thread. 436 // IO thread.
406 MessageLoop* io_loop_; 437 MessageLoop* io_loop_;
407 438
408 // A timer that periodically calls UpdateLoadStates while pending_requests_ 439 // A timer that periodically calls UpdateLoadStates while pending_requests_
(...skipping 24 matching lines...) Expand all
433 ObserverList<Observer> observer_list_; 464 ObserverList<Observer> observer_list_;
434 465
435 PluginService* plugin_service_; 466 PluginService* plugin_service_;
436 467
437 // For running tasks. 468 // For running tasks.
438 ScopedRunnableMethodFactory<ResourceDispatcherHost> method_runner_; 469 ScopedRunnableMethodFactory<ResourceDispatcherHost> method_runner_;
439 470
440 // True if the resource dispatcher host has been shut down. 471 // True if the resource dispatcher host has been shut down.
441 bool is_shutdown_; 472 bool is_shutdown_;
442 473
474 typedef std::vector<BlockedRequest> BlockedRequestsList;
475 typedef std::pair<int, int> ProcessRendererIDs;
476 typedef std::map<ProcessRendererIDs, BlockedRequestsList*> BlockedRequestMap;
477 BlockedRequestMap blocked_requests_map_;
478
443 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); 479 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost);
444 }; 480 };
445 481
446 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ 482 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/interstitial_page.cc ('k') | chrome/browser/renderer_host/resource_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698