OLD | NEW |
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 "content/browser/fileapi/chrome_blob_storage_context.h" | 5 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "content/public/browser/blob_handle.h" | 9 #include "content/public/browser/blob_handle.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 void ChromeBlobStorageContext::InitializeOnIOThread() { | 62 void ChromeBlobStorageContext::InitializeOnIOThread() { |
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
64 context_.reset(new BlobStorageContext()); | 64 context_.reset(new BlobStorageContext()); |
65 } | 65 } |
66 | 66 |
67 scoped_ptr<BlobHandle> ChromeBlobStorageContext::CreateMemoryBackedBlob( | 67 scoped_ptr<BlobHandle> ChromeBlobStorageContext::CreateMemoryBackedBlob( |
68 const char* data, size_t length) { | 68 const char* data, size_t length) { |
69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
70 | 70 |
71 std::string uuid(base::GenerateGUID()); | 71 std::string uuid(base::GenerateGUID()); |
72 scoped_ptr<storage::BlobDataBuilder> blob_data_builder( | 72 storage::BlobDataBuilder blob_data_builder(uuid); |
73 new storage::BlobDataBuilder(uuid)); | 73 blob_data_builder.AppendData(data, length); |
74 blob_data_builder->AppendData(data, length); | |
75 | 74 |
76 scoped_ptr<storage::BlobDataHandle> blob_data_handle = | 75 scoped_ptr<storage::BlobDataHandle> blob_data_handle = |
77 context_->AddFinishedBlob(*blob_data_builder.get()); | 76 context_->AddFinishedBlob(&blob_data_builder); |
78 if (!blob_data_handle) | 77 if (!blob_data_handle) |
79 return scoped_ptr<BlobHandle>(); | 78 return scoped_ptr<BlobHandle>(); |
80 | 79 |
81 scoped_ptr<BlobHandle> blob_handle( | 80 scoped_ptr<BlobHandle> blob_handle( |
82 new BlobHandleImpl(blob_data_handle.Pass())); | 81 new BlobHandleImpl(blob_data_handle.Pass())); |
83 return blob_handle.Pass(); | 82 return blob_handle.Pass(); |
84 } | 83 } |
85 | 84 |
86 ChromeBlobStorageContext::~ChromeBlobStorageContext() {} | 85 ChromeBlobStorageContext::~ChromeBlobStorageContext() {} |
87 | 86 |
88 void ChromeBlobStorageContext::DeleteOnCorrectThread() const { | 87 void ChromeBlobStorageContext::DeleteOnCorrectThread() const { |
89 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && | 88 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && |
90 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 89 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
91 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 90 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
92 return; | 91 return; |
93 } | 92 } |
94 delete this; | 93 delete this; |
95 } | 94 } |
96 | 95 |
97 } // namespace content | 96 } // namespace content |
OLD | NEW |