| 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 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "webkit/browser/blob/blob_data_handle.h" | 14 #include "webkit/browser/blob/blob_data_handle.h" |
| 15 #include "webkit/browser/webkit_storage_browser_export.h" | 15 #include "webkit/browser/webkit_storage_browser_export.h" |
| 16 #include "webkit/common/blob/blob_data.h" | 16 #include "webkit/common/blob/blob_data.h" |
| 17 | 17 |
| 18 class GURL; | 18 class GURL; |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class FilePath; | 21 class FilePath; |
| 22 class Time; | 22 class Time; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { |
| 26 class BlobStorageHost; |
| 27 } |
| 28 |
| 25 namespace webkit_blob { | 29 namespace webkit_blob { |
| 26 | 30 |
| 27 class BlobDataHandle; | 31 class BlobDataHandle; |
| 28 | 32 |
| 29 // This class handles the logistics of blob Storage within the browser process, | 33 // This class handles the logistics of blob Storage within the browser process, |
| 30 // and maintains a mapping from blob uuid to the data. The class is single | 34 // and maintains a mapping from blob uuid to the data. The class is single |
| 31 // threaded and should only be used on the IO thread. | 35 // threaded and should only be used on the IO thread. |
| 32 // In chromium, there is one instance per profile. | 36 // In chromium, there is one instance per profile. |
| 33 class WEBKIT_STORAGE_BROWSER_EXPORT BlobStorageContext | 37 class WEBKIT_STORAGE_BROWSER_EXPORT BlobStorageContext |
| 34 : public base::SupportsWeakPtr<BlobStorageContext> { | 38 : public base::SupportsWeakPtr<BlobStorageContext> { |
| 35 public: | 39 public: |
| 36 BlobStorageContext(); | 40 BlobStorageContext(); |
| 37 ~BlobStorageContext(); | 41 ~BlobStorageContext(); |
| 38 | 42 |
| 39 scoped_ptr<BlobDataHandle> GetBlobDataFromUUID(const std::string& uuid); | 43 scoped_ptr<BlobDataHandle> GetBlobDataFromUUID(const std::string& uuid); |
| 40 scoped_ptr<BlobDataHandle> GetBlobDataFromPublicURL(const GURL& url); | 44 scoped_ptr<BlobDataHandle> GetBlobDataFromPublicURL(const GURL& url); |
| 41 | 45 |
| 42 // Useful for coining blobs from within the browser process. If the | 46 // Useful for coining blobs from within the browser process. If the |
| 43 // blob cannot be added due to memory consumption, returns NULL. | 47 // blob cannot be added due to memory consumption, returns NULL. |
| 44 scoped_ptr<BlobDataHandle> AddFinishedBlob(const BlobData* blob_data); | 48 scoped_ptr<BlobDataHandle> AddFinishedBlob(const BlobData* blob_data); |
| 45 | 49 |
| 46 // Useful for coining blob urls from within the browser process. | 50 // Useful for coining blob urls from within the browser process. |
| 47 bool RegisterPublicBlobURL(const GURL& url, const std::string& uuid); | 51 bool RegisterPublicBlobURL(const GURL& url, const std::string& uuid); |
| 48 void RevokePublicBlobURL(const GURL& url); | 52 void RevokePublicBlobURL(const GURL& url); |
| 49 | 53 |
| 50 private: | 54 private: |
| 55 friend class content::BlobStorageHost; |
| 51 friend class BlobDataHandle; | 56 friend class BlobDataHandle; |
| 52 friend class BlobStorageHost; | |
| 53 friend class ViewBlobInternalsJob; | 57 friend class ViewBlobInternalsJob; |
| 54 | 58 |
| 55 enum EntryFlags { | 59 enum EntryFlags { |
| 56 BEING_BUILT = 1 << 0, | 60 BEING_BUILT = 1 << 0, |
| 57 EXCEEDED_MEMORY = 1 << 1, | 61 EXCEEDED_MEMORY = 1 << 1, |
| 58 }; | 62 }; |
| 59 | 63 |
| 60 struct BlobMapEntry { | 64 struct BlobMapEntry { |
| 61 int refcount; | 65 int refcount; |
| 62 int flags; | 66 int flags; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // we count only the items of TYPE_DATA which are held in memory and not | 109 // we count only the items of TYPE_DATA which are held in memory and not |
| 106 // items of TYPE_FILE. | 110 // items of TYPE_FILE. |
| 107 int64 memory_usage_; | 111 int64 memory_usage_; |
| 108 | 112 |
| 109 DISALLOW_COPY_AND_ASSIGN(BlobStorageContext); | 113 DISALLOW_COPY_AND_ASSIGN(BlobStorageContext); |
| 110 }; | 114 }; |
| 111 | 115 |
| 112 } // namespace webkit_blob | 116 } // namespace webkit_blob |
| 113 | 117 |
| 114 #endif // WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ | 118 #endif // WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ |
| OLD | NEW |