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