OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_resource_protocols.h" | 5 #include "chrome/browser/extensions/extension_resource_protocols.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" |
10 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
11 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
12 #include "chrome/common/extensions/extension_file_util.h" | 13 #include "chrome/common/extensions/extension_file_util.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
14 #include "net/url_request/url_request_file_job.h" | 15 #include "net/url_request/url_request_file_job.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 base::FilePath ResolvePath(const GURL& url) { | 19 base::FilePath ResolvePath(const GURL& url) { |
19 base::FilePath root_path; | 20 base::FilePath root_path; |
20 PathService::Get(chrome::DIR_RESOURCES_EXTENSION, &root_path); | 21 PathService::Get(chrome::DIR_RESOURCES_EXTENSION, &root_path); |
21 return extension_file_util::ExtensionResourceURLToFilePath(url, root_path); | 22 return extension_file_util::ExtensionResourceURLToFilePath(url, root_path); |
22 } | 23 } |
23 | 24 |
24 class ExtensionResourcesJob : public net::URLRequestFileJob { | 25 class ExtensionResourcesJob : public net::URLRequestFileJob { |
25 public: | 26 public: |
26 ExtensionResourcesJob(net::URLRequest* request, | 27 ExtensionResourcesJob(net::URLRequest* request, |
27 net::NetworkDelegate* network_delegate) | 28 net::NetworkDelegate* network_delegate) |
28 : net::URLRequestFileJob(request, network_delegate, base::FilePath()), | 29 : net::URLRequestFileJob( |
29 weak_ptr_factory_(this) { | 30 request, network_delegate, base::FilePath(), |
30 } | 31 content::BrowserThread::GetBlockingPool()-> |
| 32 GetTaskRunnerWithShutdownBehavior( |
| 33 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), |
| 34 weak_ptr_factory_(this) {} |
31 | 35 |
32 virtual void Start() OVERRIDE; | 36 virtual void Start() OVERRIDE; |
33 | 37 |
34 protected: | 38 protected: |
35 virtual ~ExtensionResourcesJob() {} | 39 virtual ~ExtensionResourcesJob() {} |
36 | 40 |
37 void ResolvePathDone(const base::FilePath& resolved_path); | 41 void ResolvePathDone(const base::FilePath& resolved_path); |
38 | 42 |
39 private: | 43 private: |
40 base::WeakPtrFactory<ExtensionResourcesJob> weak_ptr_factory_; | 44 base::WeakPtrFactory<ExtensionResourcesJob> weak_ptr_factory_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | 84 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
81 return new ExtensionResourcesJob(request, network_delegate); | 85 return new ExtensionResourcesJob(request, network_delegate); |
82 } | 86 } |
83 | 87 |
84 } // namespace | 88 } // namespace |
85 | 89 |
86 net::URLRequestJobFactory::ProtocolHandler* | 90 net::URLRequestJobFactory::ProtocolHandler* |
87 CreateExtensionResourceProtocolHandler() { | 91 CreateExtensionResourceProtocolHandler() { |
88 return new ExtensionResourceProtocolHandler(); | 92 return new ExtensionResourceProtocolHandler(); |
89 } | 93 } |
OLD | NEW |