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

Side by Side Diff: webkit/blob/blob_storage_controller.cc

Issue 10828252: Support FileSystem URL in File object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 8 years, 3 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 | « webkit/blob/blob_storage_controller.h ('k') | webkit/blob/blob_url_request_job.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "webkit/blob/blob_storage_controller.h" 5 #include "webkit/blob/blob_storage_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "webkit/blob/blob_data.h" 9 #include "webkit/blob/blob_data.h"
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 BlobData* target_blob_data = found->second; 57 BlobData* target_blob_data = found->second;
58 DCHECK(target_blob_data); 58 DCHECK(target_blob_data);
59 59
60 memory_usage_ -= target_blob_data->GetMemoryUsage(); 60 memory_usage_ -= target_blob_data->GetMemoryUsage();
61 61
62 // The blob data is stored in the "canonical" way. That is, it only contains a 62 // The blob data is stored in the "canonical" way. That is, it only contains a
63 // list of Data and File items. 63 // list of Data and File items.
64 // 1) The Data item is denoted by the raw data and the range. 64 // 1) The Data item is denoted by the raw data and the range.
65 // 2) The File item is denoted by the file path, the range and the expected 65 // 2) The File item is denoted by the file path, the range and the expected
66 // modification time. 66 // modification time.
67 // 3) The FileSystem File item is denoted by the FileSystem URL, the range
68 // and the expected modification time.
67 // All the Blob items in the passing blob data are resolved and expanded into 69 // All the Blob items in the passing blob data are resolved and expanded into
68 // a set of Data and File items. 70 // a set of Data and File items.
69 71
70 DCHECK(item.length() > 0); 72 DCHECK(item.length() > 0);
71 switch (item.type()) { 73 switch (item.type()) {
72 case BlobData::Item::TYPE_BYTES: 74 case BlobData::Item::TYPE_BYTES:
73 DCHECK(!item.offset()); 75 DCHECK(!item.offset());
74 target_blob_data->AppendData(item.bytes(), item.length()); 76 target_blob_data->AppendData(item.bytes(), item.length());
75 break; 77 break;
76 case BlobData::Item::TYPE_FILE: 78 case BlobData::Item::TYPE_FILE:
77 AppendFileItem(target_blob_data, 79 AppendFileItem(target_blob_data,
78 item.path(), 80 item.path(),
79 item.offset(), 81 item.offset(),
80 item.length(), 82 item.length(),
81 item.expected_modification_time()); 83 item.expected_modification_time());
82 break; 84 break;
85 case BlobData::Item::TYPE_FILE_FILESYSTEM:
86 AppendFileSystemFileItem(target_blob_data,
87 item.url(),
88 item.offset(),
89 item.length(),
90 item.expected_modification_time());
91 break;
83 case BlobData::Item::TYPE_BLOB: { 92 case BlobData::Item::TYPE_BLOB: {
84 BlobData* src_blob_data = GetBlobDataFromUrl(item.url()); 93 BlobData* src_blob_data = GetBlobDataFromUrl(item.url());
85 DCHECK(src_blob_data); 94 DCHECK(src_blob_data);
86 if (src_blob_data) 95 if (src_blob_data)
87 AppendStorageItems(target_blob_data, 96 AppendStorageItems(target_blob_data,
88 src_blob_data, 97 src_blob_data,
89 item.offset(), 98 item.offset(),
90 item.length()); 99 item.length());
91 break; 100 break;
92 } 101 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 target_blob_data->AppendFile(file_path, offset, length, 220 target_blob_data->AppendFile(file_path, offset, length,
212 expected_modification_time); 221 expected_modification_time);
213 222
214 // It may be a temporary file that should be deleted when no longer needed. 223 // It may be a temporary file that should be deleted when no longer needed.
215 scoped_refptr<ShareableFileReference> shareable_file = 224 scoped_refptr<ShareableFileReference> shareable_file =
216 ShareableFileReference::Get(file_path); 225 ShareableFileReference::Get(file_path);
217 if (shareable_file) 226 if (shareable_file)
218 target_blob_data->AttachShareableFileReference(shareable_file); 227 target_blob_data->AttachShareableFileReference(shareable_file);
219 } 228 }
220 229
230 void BlobStorageController::AppendFileSystemFileItem(
231 BlobData* target_blob_data,
232 const GURL& url, uint64 offset, uint64 length,
233 const base::Time& expected_modification_time) {
234 target_blob_data->AppendFileSystemFile(url, offset, length,
235 expected_modification_time);
236 }
237
221 void BlobStorageController::IncrementBlobDataUsage(BlobData* blob_data) { 238 void BlobStorageController::IncrementBlobDataUsage(BlobData* blob_data) {
222 blob_data_usage_count_[blob_data] += 1; 239 blob_data_usage_count_[blob_data] += 1;
223 } 240 }
224 241
225 bool BlobStorageController::DecrementBlobDataUsage(BlobData* blob_data) { 242 bool BlobStorageController::DecrementBlobDataUsage(BlobData* blob_data) {
226 BlobDataUsageMap::iterator found = blob_data_usage_count_.find(blob_data); 243 BlobDataUsageMap::iterator found = blob_data_usage_count_.find(blob_data);
227 DCHECK(found != blob_data_usage_count_.end()); 244 DCHECK(found != blob_data_usage_count_.end());
228 if (--(found->second)) 245 if (--(found->second))
229 return false; // Still in use 246 return false; // Still in use
230 blob_data_usage_count_.erase(found); 247 blob_data_usage_count_.erase(found);
231 return true; 248 return true;
232 } 249 }
233 250
234 } // namespace webkit_blob 251 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/blob/blob_storage_controller.h ('k') | webkit/blob/blob_url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698