Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 CONTENT_BROWSER_BLOB_STORAGE_BLOB_URL_LOADER_FACTORY_H_ | |
| 6 #define CONTENT_BROWSER_BLOB_STORAGE_BLOB_URL_LOADER_FACTORY_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "content/common/content_export.h" | |
| 11 #include "content/common/url_loader_factory.mojom.h" | |
| 12 #include "content/public/browser/browser_thread.h" | |
| 13 #include "mojo/public/cpp/bindings/binding_set.h" | |
| 14 | |
| 15 namespace storage { | |
| 16 class BlobStorageContext; | |
| 17 class FileSystemContext; | |
| 18 } | |
| 19 | |
| 20 namespace content { | |
| 21 | |
| 22 // A class for creating URLLoaderFactory for blob scheme. | |
| 23 // There should be one owned per StoragePartition. | |
| 24 class BlobURLLoaderFactory | |
| 25 : public base::RefCountedThreadSafe<BlobURLLoaderFactory, | |
| 26 BrowserThread::DeleteOnIOThread>, | |
| 27 public mojom::URLLoaderFactory { | |
| 28 public: | |
| 29 CONTENT_EXPORT BlobURLLoaderFactory( | |
| 30 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | |
| 31 scoped_refptr<storage::FileSystemContext> file_system_context); | |
| 32 | |
| 33 // Creates a URLLoaderFactory interface pointer for serving blob requests. | |
| 34 // Called on the UI thread. | |
| 35 mojom::URLLoaderFactoryPtr CreateFactory(); | |
| 36 | |
| 37 // mojom::URLLoaderFactory implementation: | |
| 38 void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest loader, | |
| 39 int32_t routing_id, | |
| 40 int32_t request_id, | |
| 41 uint32_t options, | |
| 42 const ResourceRequest& request, | |
| 43 mojom::URLLoaderClientPtr client) override; | |
| 44 void SyncLoad(int32_t routing_id, | |
| 45 int32_t request_id, | |
| 46 const ResourceRequest& request, | |
| 47 SyncLoadCallback callback) override; | |
| 48 | |
| 49 private: | |
| 50 friend class base::DeleteHelper<BlobURLLoaderFactory>; | |
| 51 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | |
| 52 | |
| 53 ~BlobURLLoaderFactory() override; | |
| 54 | |
| 55 void BindOnIO(mojom::URLLoaderFactoryRequest request); | |
| 56 | |
| 57 // Safe to have a raw pointer since the IO thread | |
|
dmurph
2017/06/02 20:10:33
nit: update comment, no longer raw pointer.
| |
| 58 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | |
| 59 scoped_refptr<storage::FileSystemContext> file_system_context_; | |
| 60 | |
| 61 // Used on the IO thread. | |
| 62 mojo::BindingSet<mojom::URLLoaderFactory> loader_factory_bindings_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(BlobURLLoaderFactory); | |
| 65 }; | |
| 66 | |
| 67 } // namespace content | |
| 68 | |
| 69 #endif // CONTENT_BROWSER_BLOB_STORAGE_BLOB_URL_LOADER_FACTORY_H_ | |
| OLD | NEW |