Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: storage/browser/blob/blob_storage_context.h

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « storage/browser/blob/blob_data_handle.cc ('k') | storage/browser/blob/blob_storage_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "storage/browser/blob/blob_data_handle.h"
15 #include "webkit/browser/webkit_storage_browser_export.h" 15 #include "storage/common/storage_export.h"
16 #include "webkit/common/blob/blob_data.h" 16 #include "storage/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 { 25 namespace content {
26 class BlobStorageHost; 26 class BlobStorageHost;
27 } 27 }
28 28
29 namespace webkit_blob { 29 namespace storage {
30 30
31 class BlobDataHandle; 31 class BlobDataHandle;
32 32
33 // 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,
34 // 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
35 // threaded and should only be used on the IO thread. 35 // threaded and should only be used on the IO thread.
36 // In chromium, there is one instance per profile. 36 // In chromium, there is one instance per profile.
37 class WEBKIT_STORAGE_BROWSER_EXPORT BlobStorageContext 37 class STORAGE_EXPORT BlobStorageContext
38 : public base::SupportsWeakPtr<BlobStorageContext> { 38 : public base::SupportsWeakPtr<BlobStorageContext> {
39 public: 39 public:
40 BlobStorageContext(); 40 BlobStorageContext();
41 ~BlobStorageContext(); 41 ~BlobStorageContext();
42 42
43 scoped_ptr<BlobDataHandle> GetBlobDataFromUUID(const std::string& uuid); 43 scoped_ptr<BlobDataHandle> GetBlobDataFromUUID(const std::string& uuid);
44 scoped_ptr<BlobDataHandle> GetBlobDataFromPublicURL(const GURL& url); 44 scoped_ptr<BlobDataHandle> GetBlobDataFromPublicURL(const GURL& url);
45 45
46 // Useful for coining blobs from within the browser process. If the 46 // Useful for coining blobs from within the browser process. If the
47 // blob cannot be added due to memory consumption, returns NULL. 47 // blob cannot be added due to memory consumption, returns NULL.
(...skipping 16 matching lines...) Expand all
64 struct BlobMapEntry { 64 struct BlobMapEntry {
65 int refcount; 65 int refcount;
66 int flags; 66 int flags;
67 scoped_refptr<BlobData> data; 67 scoped_refptr<BlobData> data;
68 68
69 BlobMapEntry(); 69 BlobMapEntry();
70 BlobMapEntry(int refcount, int flags, BlobData* data); 70 BlobMapEntry(int refcount, int flags, BlobData* data);
71 ~BlobMapEntry(); 71 ~BlobMapEntry();
72 }; 72 };
73 73
74 typedef std::map<std::string, BlobMapEntry> 74 typedef std::map<std::string, BlobMapEntry> BlobMap;
75 BlobMap;
76 typedef std::map<GURL, std::string> BlobURLMap; 75 typedef std::map<GURL, std::string> BlobURLMap;
77 76
78 void StartBuildingBlob(const std::string& uuid); 77 void StartBuildingBlob(const std::string& uuid);
79 void AppendBlobDataItem(const std::string& uuid, 78 void AppendBlobDataItem(const std::string& uuid,
80 const BlobData::Item& data_item); 79 const BlobData::Item& data_item);
81 void FinishBuildingBlob(const std::string& uuid, const std::string& type); 80 void FinishBuildingBlob(const std::string& uuid, const std::string& type);
82 void CancelBuildingBlob(const std::string& uuid); 81 void CancelBuildingBlob(const std::string& uuid);
83 void IncrementBlobRefCount(const std::string& uuid); 82 void IncrementBlobRefCount(const std::string& uuid);
84 void DecrementBlobRefCount(const std::string& uuid); 83 void DecrementBlobRefCount(const std::string& uuid);
85 84
86 bool ExpandStorageItems(BlobData* target_blob_data, 85 bool ExpandStorageItems(BlobData* target_blob_data,
87 BlobData* src_blob_data, 86 BlobData* src_blob_data,
88 uint64 offset, 87 uint64 offset,
89 uint64 length); 88 uint64 length);
90 bool AppendBytesItem(BlobData* target_blob_data, 89 bool AppendBytesItem(BlobData* target_blob_data,
91 const char* data, int64 length); 90 const char* data,
91 int64 length);
92 void AppendFileItem(BlobData* target_blob_data, 92 void AppendFileItem(BlobData* target_blob_data,
93 const base::FilePath& file_path, 93 const base::FilePath& file_path,
94 uint64 offset, uint64 length, 94 uint64 offset,
95 uint64 length,
95 const base::Time& expected_modification_time); 96 const base::Time& expected_modification_time);
96 void AppendFileSystemFileItem( 97 void AppendFileSystemFileItem(BlobData* target_blob_data,
97 BlobData* target_blob_data, 98 const GURL& url,
98 const GURL& url, uint64 offset, uint64 length, 99 uint64 offset,
99 const base::Time& expected_modification_time); 100 uint64 length,
101 const base::Time& expected_modification_time);
100 102
101 bool IsInUse(const std::string& uuid); 103 bool IsInUse(const std::string& uuid);
102 bool IsBeingBuilt(const std::string& uuid); 104 bool IsBeingBuilt(const std::string& uuid);
103 bool IsUrlRegistered(const GURL& blob_url); 105 bool IsUrlRegistered(const GURL& blob_url);
104 106
105 BlobMap blob_map_; 107 BlobMap blob_map_;
106 BlobURLMap public_blob_urls_; 108 BlobURLMap public_blob_urls_;
107 109
108 // Used to keep track of how much memory is being utilized for blob data, 110 // Used to keep track of how much memory is being utilized for blob data,
109 // we count only the items of TYPE_DATA which are held in memory and not 111 // we count only the items of TYPE_DATA which are held in memory and not
110 // items of TYPE_FILE. 112 // items of TYPE_FILE.
111 int64 memory_usage_; 113 int64 memory_usage_;
112 114
113 DISALLOW_COPY_AND_ASSIGN(BlobStorageContext); 115 DISALLOW_COPY_AND_ASSIGN(BlobStorageContext);
114 }; 116 };
115 117
116 } // namespace webkit_blob 118 } // namespace storage
117 119
118 #endif // WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ 120 #endif // WEBKIT_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_
OLDNEW
« no previous file with comments | « storage/browser/blob/blob_data_handle.cc ('k') | storage/browser/blob/blob_storage_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698