diff options
author | earthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-19 13:14:29 +0000 |
---|---|---|
committer | earthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-19 13:14:29 +0000 |
commit | 255620da4ddf6f59947d9e77529f54ad02d9af12 (patch) | |
tree | 3259bcf1524fa26fd8099e409af35422d82f9871 /chrome/browser/extensions | |
parent | 6a1162f6cff7d33880f5e03fb9bb3909d84e7beb (diff) | |
download | chromium_src-255620da4ddf6f59947d9e77529f54ad02d9af12.zip chromium_src-255620da4ddf6f59947d9e77529f54ad02d9af12.tar.gz chromium_src-255620da4ddf6f59947d9e77529f54ad02d9af12.tar.bz2 |
Remove WorkerPool dependency from URLRequestFileJob.
Make net::URLRequestFileJob pass a TaskRunner to FileStream, instead of using a deprecated FileStream constructor that depends on WorkerPool. This TaskRunner is obtained from the blocking pool where possible. Also, remove two explicit uses of WorkerPool in net/url_request/ and chrome/browser/.
Removes dependency on deprecated code. Also fixes memory leaks in unit tests caused by FileStream destruction tasks not running to completion in WorkerPool.
BUG=248513, 251774
Review URL: https://chromiumcodereview.appspot.com/22795006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218273 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension_protocols.cc | 19 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_resource_protocols.cc | 10 |
2 files changed, 18 insertions, 11 deletions
diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc index fdafe9f..25ef06b 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -19,8 +19,8 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/threading/sequenced_worker_pool.h" #include "base/threading/thread_restrictions.h" -#include "base/threading/worker_pool.h" #include "build/build_config.h" #include "chrome/browser/extensions/extension_info_map.h" #include "chrome/browser/extensions/image_loader.h" @@ -35,6 +35,7 @@ #include "chrome/common/extensions/manifest_url_handler.h" #include "chrome/common/extensions/web_accessible_resources_handler.h" #include "chrome/common/url_constants.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/resource_request_info.h" #include "extensions/common/constants.h" #include "extensions/common/extension_resource.h" @@ -136,7 +137,7 @@ class URLRequestResourceBundleJob : public net::URLRequestSimpleJob { std::string* read_mime_type = new std::string; bool* read_result = new bool; - bool posted = base::WorkerPool::PostTaskAndReply( + bool posted = content::BrowserThread::PostBlockingPoolTaskAndReply( FROM_HERE, base::Bind(&ReadMimeTypeFromFile, filename_, base::Unretained(read_mime_type), @@ -146,8 +147,7 @@ class URLRequestResourceBundleJob : public net::URLRequestSimpleJob { mime_type, charset, data, base::Owned(read_mime_type), base::Owned(read_result), - callback), - true /* task is slow */); + callback)); DCHECK(posted); return net::ERR_IO_PENDING; @@ -251,7 +251,11 @@ class URLRequestExtensionJob : public net::URLRequestFileJob { const base::FilePath& relative_path, const std::string& content_security_policy, bool send_cors_header) - : net::URLRequestFileJob(request, network_delegate, base::FilePath()), + : net::URLRequestFileJob( + request, network_delegate, base::FilePath(), + content::BrowserThread::GetBlockingPool()-> + GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), // TODO(tc): Move all of these files into resources.pak so we don't break // when updating on Linux. resource_(extension_id, directory_path, relative_path), @@ -267,7 +271,7 @@ class URLRequestExtensionJob : public net::URLRequestFileJob { virtual void Start() OVERRIDE { base::FilePath* read_file_path = new base::FilePath; base::Time* last_modified_time = new base::Time(); - bool posted = base::WorkerPool::PostTaskAndReply( + bool posted = content::BrowserThread::PostBlockingPoolTaskAndReply( FROM_HERE, base::Bind(&ReadResourceFilePathAndLastModifiedTime, resource_, base::Unretained(read_file_path), @@ -275,8 +279,7 @@ class URLRequestExtensionJob : public net::URLRequestFileJob { base::Bind(&URLRequestExtensionJob::OnFilePathAndLastModifiedTimeRead, weak_factory_.GetWeakPtr(), base::Owned(read_file_path), - base::Owned(last_modified_time)), - true /* task is slow */); + base::Owned(last_modified_time))); DCHECK(posted); } diff --git a/chrome/browser/extensions/extension_resource_protocols.cc b/chrome/browser/extensions/extension_resource_protocols.cc index 565b08b..eb75df9 100644 --- a/chrome/browser/extensions/extension_resource_protocols.cc +++ b/chrome/browser/extensions/extension_resource_protocols.cc @@ -7,6 +7,7 @@ #include "base/files/file_path.h" #include "base/memory/weak_ptr.h" #include "base/path_service.h" +#include "base/threading/sequenced_worker_pool.h" #include "base/threading/thread_checker.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/extensions/extension_file_util.h" @@ -25,9 +26,12 @@ class ExtensionResourcesJob : public net::URLRequestFileJob { public: ExtensionResourcesJob(net::URLRequest* request, net::NetworkDelegate* network_delegate) - : net::URLRequestFileJob(request, network_delegate, base::FilePath()), - weak_ptr_factory_(this) { - } + : net::URLRequestFileJob( + request, network_delegate, base::FilePath(), + content::BrowserThread::GetBlockingPool()-> + GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), + weak_ptr_factory_(this) {} virtual void Start() OVERRIDE; |