| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ | 5 #ifndef WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ |
| 6 #define WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ | 6 #define WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 scoped_ptr<BlobDataHandle> GetBlobDataFromPublicURL(const GURL& url); | 40 scoped_ptr<BlobDataHandle> GetBlobDataFromPublicURL(const GURL& url); |
| 41 | 41 |
| 42 // Useful for coining blobs from within the browser process. If the | 42 // Useful for coining blobs from within the browser process. If the |
| 43 // blob cannot be added due to memory consumption, returns NULL. | 43 // blob cannot be added due to memory consumption, returns NULL. |
| 44 scoped_ptr<BlobDataHandle> AddFinishedBlob(const BlobData* blob_data); | 44 scoped_ptr<BlobDataHandle> AddFinishedBlob(const BlobData* blob_data); |
| 45 | 45 |
| 46 // Useful for coining blob urls from within the browser process. | 46 // Useful for coining blob urls from within the browser process. |
| 47 bool RegisterPublicBlobURL(const GURL& url, const std::string& uuid); | 47 bool RegisterPublicBlobURL(const GURL& url, const std::string& uuid); |
| 48 void RevokePublicBlobURL(const GURL& url); | 48 void RevokePublicBlobURL(const GURL& url); |
| 49 | 49 |
| 50 // Temporary support for mapping oldstyle blobUrls to new style uuids. | |
| 51 std::string LookupUuidFromDeprecatedURL(const GURL& url); | |
| 52 | |
| 53 private: | 50 private: |
| 54 friend class BlobDataHandle; | 51 friend class BlobDataHandle; |
| 55 friend class BlobStorageHost; | 52 friend class BlobStorageHost; |
| 56 friend class ViewBlobInternalsJob; | 53 friend class ViewBlobInternalsJob; |
| 57 | 54 |
| 58 enum EntryFlags { | 55 enum EntryFlags { |
| 59 BEING_BUILT = 1 << 0, | 56 BEING_BUILT = 1 << 0, |
| 60 EXCEEDED_MEMORY = 1 << 1, | 57 EXCEEDED_MEMORY = 1 << 1, |
| 61 }; | 58 }; |
| 62 | 59 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 75 typedef std::map<GURL, std::string> BlobURLMap; | 72 typedef std::map<GURL, std::string> BlobURLMap; |
| 76 | 73 |
| 77 void StartBuildingBlob(const std::string& uuid); | 74 void StartBuildingBlob(const std::string& uuid); |
| 78 void AppendBlobDataItem(const std::string& uuid, | 75 void AppendBlobDataItem(const std::string& uuid, |
| 79 const BlobData::Item& data_item); | 76 const BlobData::Item& data_item); |
| 80 void FinishBuildingBlob(const std::string& uuid, const std::string& type); | 77 void FinishBuildingBlob(const std::string& uuid, const std::string& type); |
| 81 void CancelBuildingBlob(const std::string& uuid); | 78 void CancelBuildingBlob(const std::string& uuid); |
| 82 void IncrementBlobRefCount(const std::string& uuid); | 79 void IncrementBlobRefCount(const std::string& uuid); |
| 83 void DecrementBlobRefCount(const std::string& uuid); | 80 void DecrementBlobRefCount(const std::string& uuid); |
| 84 | 81 |
| 85 // Temporary support for mapping old style blobUrls to new style uuids. | |
| 86 void DeprecatedRegisterPrivateBlobURL(const GURL& url, | |
| 87 const std::string& uuid); | |
| 88 void DeprecatedRevokePrivateBlobURL(const GURL& url); | |
| 89 | |
| 90 bool ExpandStorageItems(BlobData* target_blob_data, | 82 bool ExpandStorageItems(BlobData* target_blob_data, |
| 91 BlobData* src_blob_data, | 83 BlobData* src_blob_data, |
| 92 uint64 offset, | 84 uint64 offset, |
| 93 uint64 length); | 85 uint64 length); |
| 94 bool AppendBytesItem(BlobData* target_blob_data, | 86 bool AppendBytesItem(BlobData* target_blob_data, |
| 95 const char* data, int64 length); | 87 const char* data, int64 length); |
| 96 void AppendFileItem(BlobData* target_blob_data, | 88 void AppendFileItem(BlobData* target_blob_data, |
| 97 const base::FilePath& file_path, | 89 const base::FilePath& file_path, |
| 98 uint64 offset, uint64 length, | 90 uint64 offset, uint64 length, |
| 99 const base::Time& expected_modification_time); | 91 const base::Time& expected_modification_time); |
| 100 void AppendFileSystemFileItem( | 92 void AppendFileSystemFileItem( |
| 101 BlobData* target_blob_data, | 93 BlobData* target_blob_data, |
| 102 const GURL& url, uint64 offset, uint64 length, | 94 const GURL& url, uint64 offset, uint64 length, |
| 103 const base::Time& expected_modification_time); | 95 const base::Time& expected_modification_time); |
| 104 | 96 |
| 105 bool IsInUse(const std::string& uuid); | 97 bool IsInUse(const std::string& uuid); |
| 106 bool IsBeingBuilt(const std::string& uuid); | 98 bool IsBeingBuilt(const std::string& uuid); |
| 107 bool IsUrlRegistered(const GURL& blob_url); | 99 bool IsUrlRegistered(const GURL& blob_url); |
| 108 | 100 |
| 109 BlobMap blob_map_; | 101 BlobMap blob_map_; |
| 110 BlobURLMap public_blob_urls_; | 102 BlobURLMap public_blob_urls_; |
| 111 BlobURLMap deprecated_blob_urls_; | |
| 112 | 103 |
| 113 // Used to keep track of how much memory is being utitlized for blob data, | 104 // Used to keep track of how much memory is being utitlized for blob data, |
| 114 // we count only the items of TYPE_DATA which are held in memory and not | 105 // we count only the items of TYPE_DATA which are held in memory and not |
| 115 // items of TYPE_FILE. | 106 // items of TYPE_FILE. |
| 116 int64 memory_usage_; | 107 int64 memory_usage_; |
| 117 | 108 |
| 118 DISALLOW_COPY_AND_ASSIGN(BlobStorageContext); | 109 DISALLOW_COPY_AND_ASSIGN(BlobStorageContext); |
| 119 }; | 110 }; |
| 120 | 111 |
| 121 } // namespace webkit_blob | 112 } // namespace webkit_blob |
| 122 | 113 |
| 123 #endif // WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ | 114 #endif // WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ |
| OLD | NEW |