OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_RESOURCE_PROVIDER_RESOURCE_PROVIDER_IMPL_H_ |
| 6 #define COMPONENTS_RESOURCE_PROVIDER_RESOURCE_PROVIDER_IMPL_H_ |
| 7 |
| 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" |
| 12 |
| 13 namespace base { |
| 14 class SequencedWorkerPool; |
| 15 } |
| 16 |
| 17 namespace resource_provider { |
| 18 |
| 19 // ResourceProvider implementation that loads resources in background threads. |
| 20 class ResourceProviderImpl : public resource_provider::ResourceProvider { |
| 21 public: |
| 22 ResourceProviderImpl(const base::FilePath& application_path, |
| 23 base::SequencedWorkerPool* blocking_pool); |
| 24 ~ResourceProviderImpl() override; |
| 25 |
| 26 private: |
| 27 struct Data; |
| 28 |
| 29 static void ReadFileOnWorkerThread(const base::FilePath& path, |
| 30 scoped_refptr<Data> data); |
| 31 void OnReadFile(scoped_refptr<Data> data, |
| 32 const GetResourceCallback& callback); |
| 33 |
| 34 void GetResource(const mojo::String& path, |
| 35 const GetResourceCallback& callback) override; |
| 36 |
| 37 const base::FilePath application_path_; |
| 38 |
| 39 scoped_refptr<base::SequencedWorkerPool> blocking_pool_; |
| 40 |
| 41 base::WeakPtrFactory<ResourceProviderImpl> weak_factory_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(ResourceProviderImpl); |
| 44 }; |
| 45 |
| 46 } // namespace resource_provider |
| 47 |
| 48 #endif // COMPONENTS_RESOURCE_PROVIDER_RESOURCE_PROVIDER_IMPL_H_ |
OLD | NEW |