| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_BROWSER_FILEAPI_STORAGE_HOST_H_ | 5 #ifndef CONTENT_BROWSER_FILEAPI_STORAGE_HOST_H_ |
| 6 #define CONTENT_BROWSER_FILEAPI_STORAGE_HOST_H_ | 6 #define CONTENT_BROWSER_FILEAPI_STORAGE_HOST_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "storage/common/blob/blob_data.h" | 15 #include "storage/common/data_element.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 | 18 |
| 19 namespace storage { | 19 namespace storage { |
| 20 class BlobDataHandle; | 20 class BlobDataHandle; |
| 21 class BlobStorageHost; | 21 class BlobStorageHost; |
| 22 class BlobStorageContext; | 22 class BlobStorageContext; |
| 23 } | 23 } |
| 24 | 24 |
| 25 using storage::BlobStorageContext; | |
| 26 using storage::BlobData; | |
| 27 | |
| 28 namespace content { | 25 namespace content { |
| 29 | 26 |
| 30 // This class handles the logistics of blob storage for a single child process. | 27 // This class handles the logistics of blob storage for a single child process. |
| 31 // There is one instance per child process. When the child process | 28 // There is one instance per child process. When the child process |
| 32 // terminates all blob references attibutable to that process go away upon | 29 // terminates all blob references attibutable to that process go away upon |
| 33 // destruction of the instance. The class is single threaded and should | 30 // destruction of the instance. The class is single threaded and should |
| 34 // only be used on the IO thread. | 31 // only be used on the IO thread. |
| 35 class CONTENT_EXPORT BlobStorageHost { | 32 class CONTENT_EXPORT BlobStorageHost { |
| 36 public: | 33 public: |
| 37 explicit BlobStorageHost(BlobStorageContext* context); | 34 explicit BlobStorageHost(storage::BlobStorageContext* context); |
| 38 ~BlobStorageHost(); | 35 ~BlobStorageHost(); |
| 39 | 36 |
| 40 // Methods to support the IPC message protocol. | 37 // Methods to support the IPC message protocol. |
| 41 // A false return indicates a problem with the inputs | 38 // A false return indicates a problem with the inputs |
| 42 // like a non-existent or pre-existent uuid or url. | 39 // like a non-existent or pre-existent uuid or url. |
| 43 bool StartBuildingBlob(const std::string& uuid) WARN_UNUSED_RESULT; | 40 bool StartBuildingBlob(const std::string& uuid) WARN_UNUSED_RESULT; |
| 44 bool AppendBlobDataItem(const std::string& uuid, | 41 bool AppendBlobDataItem(const std::string& uuid, |
| 45 const BlobData::Item& data_item) WARN_UNUSED_RESULT; | 42 const storage::DataElement& data_item) |
| 43 WARN_UNUSED_RESULT; |
| 46 bool CancelBuildingBlob(const std::string& uuid) WARN_UNUSED_RESULT; | 44 bool CancelBuildingBlob(const std::string& uuid) WARN_UNUSED_RESULT; |
| 47 bool FinishBuildingBlob(const std::string& uuid, | 45 bool FinishBuildingBlob(const std::string& uuid, |
| 48 const std::string& type) WARN_UNUSED_RESULT; | 46 const std::string& type) WARN_UNUSED_RESULT; |
| 49 bool IncrementBlobRefCount(const std::string& uuid) WARN_UNUSED_RESULT; | 47 bool IncrementBlobRefCount(const std::string& uuid) WARN_UNUSED_RESULT; |
| 50 bool DecrementBlobRefCount(const std::string& uuid) WARN_UNUSED_RESULT; | 48 bool DecrementBlobRefCount(const std::string& uuid) WARN_UNUSED_RESULT; |
| 51 bool RegisterPublicBlobURL(const GURL& blob_url, | 49 bool RegisterPublicBlobURL(const GURL& blob_url, |
| 52 const std::string& uuid) WARN_UNUSED_RESULT; | 50 const std::string& uuid) WARN_UNUSED_RESULT; |
| 53 bool RevokePublicBlobURL(const GURL& blob_url) WARN_UNUSED_RESULT; | 51 bool RevokePublicBlobURL(const GURL& blob_url) WARN_UNUSED_RESULT; |
| 54 | 52 |
| 55 private: | 53 private: |
| 56 typedef std::map<std::string, int> BlobReferenceMap; | 54 typedef std::map<std::string, int> BlobReferenceMap; |
| 57 | 55 |
| 58 bool IsInUseInHost(const std::string& uuid); | 56 bool IsInUseInHost(const std::string& uuid); |
| 59 bool IsBeingBuiltInHost(const std::string& uuid); | 57 bool IsBeingBuiltInHost(const std::string& uuid); |
| 60 bool IsUrlRegisteredInHost(const GURL& blob_url); | 58 bool IsUrlRegisteredInHost(const GURL& blob_url); |
| 61 | 59 |
| 62 // Collection of blob ids and a count of how many usages | 60 // Collection of blob ids and a count of how many usages |
| 63 // of that id are attributable to this consumer. | 61 // of that id are attributable to this consumer. |
| 64 BlobReferenceMap blobs_inuse_map_; | 62 BlobReferenceMap blobs_inuse_map_; |
| 65 | 63 |
| 66 // The set of public blob urls coined by this consumer. | 64 // The set of public blob urls coined by this consumer. |
| 67 std::set<GURL> public_blob_urls_; | 65 std::set<GURL> public_blob_urls_; |
| 68 | 66 |
| 69 base::WeakPtr<BlobStorageContext> context_; | 67 base::WeakPtr<storage::BlobStorageContext> context_; |
| 70 | 68 |
| 71 DISALLOW_COPY_AND_ASSIGN(BlobStorageHost); | 69 DISALLOW_COPY_AND_ASSIGN(BlobStorageHost); |
| 72 }; | 70 }; |
| 73 | 71 |
| 74 } // namespace content | 72 } // namespace content |
| 75 | 73 |
| 76 #endif // CONTENT_BROWSER_FILEAPI_STORAGE_HOST_H_ | 74 #endif // CONTENT_BROWSER_FILEAPI_STORAGE_HOST_H_ |
| OLD | NEW |