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

Side by Side Diff: chrome/browser/renderer_host/buffered_resource_handler.cc

Issue 342090: Use ChromeThread::DeleteOnIOThread in a few places where an object must be de... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/renderer_host/buffered_resource_handler.h" 5 #include "chrome/browser/renderer_host/buffered_resource_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_thread.h" 12 #include "chrome/browser/chrome_thread.h"
14 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" 13 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h"
15 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 14 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
16 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" 15 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
17 #include "chrome/browser/renderer_host/x509_user_cert_resource_handler.h" 16 #include "chrome/browser/renderer_host/x509_user_cert_resource_handler.h"
18 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
19 #include "net/base/io_buffer.h" 18 #include "net/base/io_buffer.h"
20 #include "net/base/mime_sniffer.h" 19 #include "net/base/mime_sniffer.h"
21 #include "net/base/mime_util.h" 20 #include "net/base/mime_util.h"
22 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 bool need_plugin_list; 388 bool need_plugin_list;
390 if (!ShouldDownload(&need_plugin_list) || !need_plugin_list) 389 if (!ShouldDownload(&need_plugin_list) || !need_plugin_list)
391 return false; 390 return false;
392 391
393 // We don't want to keep buffering as our buffer will fill up. 392 // We don't want to keep buffering as our buffer will fill up.
394 ResourceDispatcherHostRequestInfo* info = 393 ResourceDispatcherHostRequestInfo* info =
395 ResourceDispatcherHost::InfoForRequest(request_); 394 ResourceDispatcherHost::InfoForRequest(request_);
396 host_->PauseRequest(info->child_id(), info->request_id(), true); 395 host_->PauseRequest(info->child_id(), info->request_id(), true);
397 396
398 // Schedule plugin loading on the file thread. 397 // Schedule plugin loading on the file thread.
399 // Note: it's possible that the only reference to this object is the task. If
400 // If the task executes on the file thread, and before it returns, the task it
401 // posts to the IO thread runs, then this object will get destructed on the
402 // file thread. This breaks assumptions in other message handlers (i.e. when
403 // unregistering with NotificationService in the destructor).
404 AddRef();
405 ChromeThread::PostTask( 398 ChromeThread::PostTask(
406 ChromeThread::FILE, FROM_HERE, 399 ChromeThread::FILE, FROM_HERE,
407 NewRunnableFunction(&BufferedResourceHandler::LoadPlugins, this)); 400 NewRunnableMethod(this, &BufferedResourceHandler::LoadPlugins));
408 return true; 401 return true;
409 } 402 }
410 403
411 // This test mirrors the decision that WebKit makes in 404 // This test mirrors the decision that WebKit makes in
412 // WebFrameLoaderClient::dispatchDecidePolicyForMIMEType. 405 // WebFrameLoaderClient::dispatchDecidePolicyForMIMEType.
413 bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { 406 bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) {
414 if (need_plugin_list) 407 if (need_plugin_list)
415 *need_plugin_list = false; 408 *need_plugin_list = false;
416 std::string type = StringToLowerASCII(response_->response_head.mime_type); 409 std::string type = StringToLowerASCII(response_->response_head.mime_type);
417 std::string disposition; 410 std::string disposition;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 DCHECK(NPAPI::PluginList::Singleton()->PluginsLoaded()); 454 DCHECK(NPAPI::PluginList::Singleton()->PluginsLoaded());
462 } 455 }
463 456
464 // Finally, check the plugin list. 457 // Finally, check the plugin list.
465 WebPluginInfo info; 458 WebPluginInfo info;
466 bool allow_wildcard = false; 459 bool allow_wildcard = false;
467 return !NPAPI::PluginList::Singleton()->GetPluginInfo( 460 return !NPAPI::PluginList::Singleton()->GetPluginInfo(
468 GURL(), type, allow_wildcard, &info, NULL); 461 GURL(), type, allow_wildcard, &info, NULL);
469 } 462 }
470 463
471 void BufferedResourceHandler::LoadPlugins(BufferedResourceHandler* handler) { 464 void BufferedResourceHandler::LoadPlugins() {
472 std::vector<WebPluginInfo> plugins; 465 std::vector<WebPluginInfo> plugins;
473 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); 466 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins);
474 467
475 ChromeThread::PostTask( 468 ChromeThread::PostTask(
476 ChromeThread::IO, FROM_HERE, 469 ChromeThread::IO, FROM_HERE,
477 NewRunnableFunction(&BufferedResourceHandler::OnPluginsLoaded, 470 NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded));
478 handler));
479 } 471 }
480 472
481 void BufferedResourceHandler::OnPluginsLoaded( 473 void BufferedResourceHandler::OnPluginsLoaded() {
482 BufferedResourceHandler* handler) { 474 wait_for_plugins_ = false;
483 handler->wait_for_plugins_ = false; 475 if (!request_)
484 if (handler->request_) { 476 return;
485 ResourceDispatcherHostRequestInfo* info = 477
486 ResourceDispatcherHost::InfoForRequest(handler->request_); 478 ResourceDispatcherHostRequestInfo* info =
487 handler->host_->PauseRequest(info->child_id(), info->request_id(), false); 479 ResourceDispatcherHost::InfoForRequest(request_);
488 if (!handler->CompleteResponseStarted(info->request_id(), false)) 480 host_->PauseRequest(info->child_id(), info->request_id(), false);
489 handler->host_->CancelRequest( 481 if (!CompleteResponseStarted(info->request_id(), false))
490 info->child_id(), info->request_id(), false); 482 host_->CancelRequest(info->child_id(), info->request_id(), false);
491 }
492 handler->Release();
493 } 483 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/buffered_resource_handler.h ('k') | chrome/browser/renderer_host/resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698