| 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/sequenced_worker_pool.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 public: | 26 public: |
| 27 ExtensionResourcesJob(net::URLRequest* request, | 27 ExtensionResourcesJob(net::URLRequest* request, |
| 28 net::NetworkDelegate* network_delegate) | 28 net::NetworkDelegate* network_delegate) |
| 29 : net::URLRequestFileJob( | 29 : net::URLRequestFileJob( |
| 30 request, network_delegate, base::FilePath(), | 30 request, network_delegate, base::FilePath(), |
| 31 content::BrowserThread::GetBlockingPool()-> | 31 content::BrowserThread::GetBlockingPool()-> |
| 32 GetTaskRunnerWithShutdownBehavior( | 32 GetTaskRunnerWithShutdownBehavior( |
| 33 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), | 33 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), |
| 34 weak_ptr_factory_(this) {} | 34 weak_ptr_factory_(this) {} |
| 35 | 35 |
| 36 virtual void Start() override; | 36 void Start() override; |
| 37 | 37 |
| 38 virtual bool IsRedirectResponse(GURL* location, | 38 bool IsRedirectResponse(GURL* location, int* http_status_code) override; |
| 39 int* http_status_code) override; | |
| 40 | 39 |
| 41 protected: | 40 protected: |
| 42 virtual ~ExtensionResourcesJob() {} | 41 ~ExtensionResourcesJob() override {} |
| 43 | 42 |
| 44 void ResolvePathDone(const base::FilePath& resolved_path); | 43 void ResolvePathDone(const base::FilePath& resolved_path); |
| 45 | 44 |
| 46 private: | 45 private: |
| 47 base::WeakPtrFactory<ExtensionResourcesJob> weak_ptr_factory_; | 46 base::WeakPtrFactory<ExtensionResourcesJob> weak_ptr_factory_; |
| 48 | 47 |
| 49 base::ThreadChecker thread_checker_; | 48 base::ThreadChecker thread_checker_; |
| 50 | 49 |
| 51 DISALLOW_COPY_AND_ASSIGN(ExtensionResourcesJob); | 50 DISALLOW_COPY_AND_ASSIGN(ExtensionResourcesJob); |
| 52 }; | 51 }; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 69 const base::FilePath& resolved_path) { | 68 const base::FilePath& resolved_path) { |
| 70 DCHECK(thread_checker_.CalledOnValidThread()); | 69 DCHECK(thread_checker_.CalledOnValidThread()); |
| 71 file_path_ = resolved_path; | 70 file_path_ = resolved_path; |
| 72 net::URLRequestFileJob::Start(); | 71 net::URLRequestFileJob::Start(); |
| 73 } | 72 } |
| 74 | 73 |
| 75 class ExtensionResourceProtocolHandler | 74 class ExtensionResourceProtocolHandler |
| 76 : public net::URLRequestJobFactory::ProtocolHandler { | 75 : public net::URLRequestJobFactory::ProtocolHandler { |
| 77 public: | 76 public: |
| 78 ExtensionResourceProtocolHandler() {} | 77 ExtensionResourceProtocolHandler() {} |
| 79 virtual ~ExtensionResourceProtocolHandler() {} | 78 ~ExtensionResourceProtocolHandler() override {} |
| 80 | 79 |
| 81 virtual net::URLRequestJob* MaybeCreateJob( | 80 net::URLRequestJob* MaybeCreateJob( |
| 82 net::URLRequest* request, | 81 net::URLRequest* request, |
| 83 net::NetworkDelegate* network_delegate) const override; | 82 net::NetworkDelegate* network_delegate) const override; |
| 84 | 83 |
| 85 private: | 84 private: |
| 86 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); | 85 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler); |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 // Creates URLRequestJobs for chrome-extension-resource:// URLs. | 88 // Creates URLRequestJobs for chrome-extension-resource:// URLs. |
| 90 net::URLRequestJob* | 89 net::URLRequestJob* |
| 91 ExtensionResourceProtocolHandler::MaybeCreateJob( | 90 ExtensionResourceProtocolHandler::MaybeCreateJob( |
| 92 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | 91 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
| 93 return new ExtensionResourcesJob(request, network_delegate); | 92 return new ExtensionResourcesJob(request, network_delegate); |
| 94 } | 93 } |
| 95 | 94 |
| 96 } // namespace | 95 } // namespace |
| 97 | 96 |
| 98 net::URLRequestJobFactory::ProtocolHandler* | 97 net::URLRequestJobFactory::ProtocolHandler* |
| 99 CreateExtensionResourceProtocolHandler() { | 98 CreateExtensionResourceProtocolHandler() { |
| 100 return new ExtensionResourceProtocolHandler(); | 99 return new ExtensionResourceProtocolHandler(); |
| 101 } | 100 } |
| OLD | NEW |