OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "content/browser/fileapi/blob_storage_host.h" | 5 #include "content/browser/fileapi/blob_storage_host.h" |
6 | 6 |
7 #include "base/sequenced_task_runner.h" | 7 #include "base/sequenced_task_runner.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "storage/browser/blob/blob_data_handle.h" | |
10 #include "storage/browser/blob/blob_storage_context.h" | 9 #include "storage/browser/blob/blob_storage_context.h" |
11 #include "url/gurl.h" | 10 #include "url/gurl.h" |
12 | 11 |
13 using storage::BlobStorageContext; | 12 using storage::BlobStorageContext; |
14 using storage::BlobData; | |
15 | 13 |
16 namespace content { | 14 namespace content { |
17 | 15 |
18 BlobStorageHost::BlobStorageHost(BlobStorageContext* context) | 16 BlobStorageHost::BlobStorageHost(BlobStorageContext* context) |
19 : context_(context->AsWeakPtr()) { | 17 : context_(context->AsWeakPtr()) { |
20 } | 18 } |
21 | 19 |
22 BlobStorageHost::~BlobStorageHost() { | 20 BlobStorageHost::~BlobStorageHost() { |
23 if (!context_.get()) | 21 if (!context_.get()) |
24 return; | 22 return; |
(...skipping 10 matching lines...) Expand all Loading... |
35 | 33 |
36 bool BlobStorageHost::StartBuildingBlob(const std::string& uuid) { | 34 bool BlobStorageHost::StartBuildingBlob(const std::string& uuid) { |
37 if (!context_.get() || uuid.empty() || context_->IsInUse(uuid)) | 35 if (!context_.get() || uuid.empty() || context_->IsInUse(uuid)) |
38 return false; | 36 return false; |
39 context_->StartBuildingBlob(uuid); | 37 context_->StartBuildingBlob(uuid); |
40 blobs_inuse_map_[uuid] = 1; | 38 blobs_inuse_map_[uuid] = 1; |
41 return true; | 39 return true; |
42 } | 40 } |
43 | 41 |
44 bool BlobStorageHost::AppendBlobDataItem( | 42 bool BlobStorageHost::AppendBlobDataItem( |
45 const std::string& uuid, const BlobData::Item& data_item) { | 43 const std::string& uuid, |
| 44 const storage::DataElement& data_item) { |
46 if (!context_.get() || !IsBeingBuiltInHost(uuid)) | 45 if (!context_.get() || !IsBeingBuiltInHost(uuid)) |
47 return false; | 46 return false; |
48 context_->AppendBlobDataItem(uuid, data_item); | 47 context_->AppendBlobDataItem(uuid, data_item); |
49 return true; | 48 return true; |
50 } | 49 } |
51 | 50 |
52 bool BlobStorageHost::CancelBuildingBlob(const std::string& uuid) { | 51 bool BlobStorageHost::CancelBuildingBlob(const std::string& uuid) { |
53 if (!context_.get() || !IsBeingBuiltInHost(uuid)) | 52 if (!context_.get() || !IsBeingBuiltInHost(uuid)) |
54 return false; | 53 return false; |
55 blobs_inuse_map_.erase(uuid); | 54 blobs_inuse_map_.erase(uuid); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 107 |
109 bool BlobStorageHost::IsBeingBuiltInHost(const std::string& uuid) { | 108 bool BlobStorageHost::IsBeingBuiltInHost(const std::string& uuid) { |
110 return IsInUseInHost(uuid) && context_->IsBeingBuilt(uuid); | 109 return IsInUseInHost(uuid) && context_->IsBeingBuilt(uuid); |
111 } | 110 } |
112 | 111 |
113 bool BlobStorageHost::IsUrlRegisteredInHost(const GURL& blob_url) { | 112 bool BlobStorageHost::IsUrlRegisteredInHost(const GURL& blob_url) { |
114 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); | 113 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); |
115 } | 114 } |
116 | 115 |
117 } // namespace content | 116 } // namespace content |
OLD | NEW |