OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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_FILEAPI_BLOB_STORAGE_HOST_IMPL_H_ |
| 6 #define CONTENT_BROWSER_FILEAPI_BLOB_STORAGE_HOST_IMPL_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
| 11 |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "content/common/content_export.h" |
| 15 #include "content/public/browser/fileapi/blob_storage_host.h" |
| 16 |
| 17 class GURL; |
| 18 |
| 19 namespace webkit_blob { |
| 20 class BlobDataHandle; |
| 21 class BlobStorageContext; |
| 22 } |
| 23 |
| 24 using webkit_blob::BlobStorageContext; |
| 25 using webkit_blob::BlobData; |
| 26 |
| 27 namespace content { |
| 28 |
| 29 // This is the implementation of BlobStorageHost. |
| 30 class CONTENT_EXPORT BlobStorageHostImpl : public BlobStorageHost { |
| 31 public: |
| 32 explicit BlobStorageHostImpl(BlobStorageContext* context); |
| 33 virtual ~BlobStorageHostImpl(); |
| 34 |
| 35 // BlobStorageHost implementation: |
| 36 virtual bool StartBuildingBlob( |
| 37 const std::string& uuid) OVERRIDE WARN_UNUSED_RESULT; |
| 38 virtual bool AppendBlobDataItem( |
| 39 const std::string& uuid, |
| 40 const BlobData::Item& data_item) OVERRIDE WARN_UNUSED_RESULT; |
| 41 virtual bool CancelBuildingBlob( |
| 42 const std::string& uuid) OVERRIDE WARN_UNUSED_RESULT; |
| 43 virtual bool FinishBuildingBlob( |
| 44 const std::string& uuid, |
| 45 const std::string& type) OVERRIDE WARN_UNUSED_RESULT; |
| 46 virtual bool IncrementBlobRefCount( |
| 47 const std::string& uuid) OVERRIDE WARN_UNUSED_RESULT; |
| 48 virtual bool DecrementBlobRefCount( |
| 49 const std::string& uuid) OVERRIDE WARN_UNUSED_RESULT; |
| 50 virtual bool RegisterPublicBlobURL( |
| 51 const GURL& blob_url, |
| 52 const std::string& uuid) OVERRIDE WARN_UNUSED_RESULT; |
| 53 virtual bool RevokePublicBlobURL( |
| 54 const GURL& blob_url) OVERRIDE WARN_UNUSED_RESULT; |
| 55 |
| 56 private: |
| 57 typedef std::map<std::string, int> BlobReferenceMap; |
| 58 |
| 59 bool IsInUseInHost(const std::string& uuid); |
| 60 bool IsBeingBuiltInHost(const std::string& uuid); |
| 61 bool IsUrlRegisteredInHost(const GURL& blob_url); |
| 62 |
| 63 // Collection of blob ids and a count of how many usages |
| 64 // of that id are attributable to this consumer. |
| 65 BlobReferenceMap blobs_inuse_map_; |
| 66 |
| 67 // The set of public blob urls coined by this consumer. |
| 68 std::set<GURL> public_blob_urls_; |
| 69 |
| 70 base::WeakPtr<BlobStorageContext> context_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(BlobStorageHostImpl); |
| 73 }; |
| 74 |
| 75 } // namespace content |
| 76 |
| 77 #endif // CONTENT_BROWSER_FILEAPI_BLOB_STORAGE_HOST_IMPL_H_ |
OLD | NEW |