Chromium Code Reviews| Index: content/browser/blob_storage/blob_url_loader_factory.h |
| diff --git a/content/browser/blob_storage/blob_url_loader_factory.h b/content/browser/blob_storage/blob_url_loader_factory.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..85c39f31f74246f4e2f010ca05a07a9b65e7526b |
| --- /dev/null |
| +++ b/content/browser/blob_storage/blob_url_loader_factory.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_BLOB_STORAGE_BLOB_URL_LOADER_FACTORY_H_ |
| +#define CONTENT_BROWSER_BLOB_STORAGE_BLOB_URL_LOADER_FACTORY_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "content/common/content_export.h" |
| +#include "content/common/url_loader_factory.mojom.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "mojo/public/cpp/bindings/binding_set.h" |
| + |
| +namespace storage { |
| +class BlobStorageContext; |
| +class FileSystemContext; |
| +} |
| + |
| +namespace content { |
| + |
| +// A class for creating URLLoaderFactory for blob scheme. |
| +// There should be one owned per StoragePartition. |
| +class BlobURLLoaderFactory |
| + : public base::RefCountedThreadSafe<BlobURLLoaderFactory, |
| + BrowserThread::DeleteOnIOThread>, |
| + public mojom::URLLoaderFactory { |
| + public: |
| + CONTENT_EXPORT BlobURLLoaderFactory( |
| + base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| + scoped_refptr<storage::FileSystemContext> file_system_context); |
| + |
| + // Creates a URLLoaderFactory interface pointer for serving blob requests. |
| + // Called on the UI thread. |
| + mojom::URLLoaderFactoryPtr CreateFactory(); |
| + |
| + // mojom::URLLoaderFactory implementation: |
| + void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest loader, |
| + int32_t routing_id, |
| + int32_t request_id, |
| + uint32_t options, |
| + const ResourceRequest& request, |
| + mojom::URLLoaderClientPtr client) override; |
| + void SyncLoad(int32_t routing_id, |
| + int32_t request_id, |
| + const ResourceRequest& request, |
| + SyncLoadCallback callback) override; |
| + |
| + private: |
| + friend class base::DeleteHelper<BlobURLLoaderFactory>; |
| + friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
| + |
| + ~BlobURLLoaderFactory() override; |
| + |
| + void BindOnIO(mojom::URLLoaderFactoryRequest request); |
| + |
| + // Safe to have a raw pointer since the IO thread |
|
dmurph
2017/06/02 20:10:33
nit: update comment, no longer raw pointer.
|
| + base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
| + scoped_refptr<storage::FileSystemContext> file_system_context_; |
| + |
| + // Used on the IO thread. |
| + mojo::BindingSet<mojom::URLLoaderFactory> loader_factory_bindings_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BlobURLLoaderFactory); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_BLOB_STORAGE_BLOB_URL_LOADER_FACTORY_H_ |