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

Side by Side Diff: content/browser/fileapi/chrome_blob_storage_context.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build 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
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 "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"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "webkit/browser/blob/blob_data_handle.h" 12 #include "webkit/browser/blob/blob_data_handle.h"
13 #include "webkit/browser/blob/blob_storage_context.h" 13 #include "webkit/browser/blob/blob_storage_context.h"
14 14
15 using base::UserDataAdapter; 15 using base::UserDataAdapter;
16 using webkit_blob::BlobStorageContext; 16 using storage::BlobStorageContext;
17 17
18 namespace content { 18 namespace content {
19 19
20 namespace { 20 namespace {
21 21
22 const char kBlobStorageContextKeyName[] = "content_blob_storage_context"; 22 const char kBlobStorageContextKeyName[] = "content_blob_storage_context";
23 23
24 class BlobHandleImpl : public BlobHandle { 24 class BlobHandleImpl : public BlobHandle {
25 public: 25 public:
26 explicit BlobHandleImpl(scoped_ptr<webkit_blob::BlobDataHandle> handle) 26 explicit BlobHandleImpl(scoped_ptr<storage::BlobDataHandle> handle)
27 : handle_(handle.Pass()) { 27 : handle_(handle.Pass()) {
28 } 28 }
29 29
30 virtual ~BlobHandleImpl() {} 30 virtual ~BlobHandleImpl() {}
31 31
32 virtual std::string GetUUID() OVERRIDE { 32 virtual std::string GetUUID() OVERRIDE {
33 return handle_->uuid(); 33 return handle_->uuid();
34 } 34 }
35 35
36 private: 36 private:
37 scoped_ptr<webkit_blob::BlobDataHandle> handle_; 37 scoped_ptr<storage::BlobDataHandle> handle_;
38 }; 38 };
39 39
40 } // namespace 40 } // namespace
41 41
42 ChromeBlobStorageContext::ChromeBlobStorageContext() {} 42 ChromeBlobStorageContext::ChromeBlobStorageContext() {}
43 43
44 ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor( 44 ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor(
45 BrowserContext* context) { 45 BrowserContext* context) {
46 if (!context->GetUserData(kBlobStorageContextKeyName)) { 46 if (!context->GetUserData(kBlobStorageContextKeyName)) {
47 scoped_refptr<ChromeBlobStorageContext> blob = 47 scoped_refptr<ChromeBlobStorageContext> blob =
(...skipping 16 matching lines...) Expand all
64 void ChromeBlobStorageContext::InitializeOnIOThread() { 64 void ChromeBlobStorageContext::InitializeOnIOThread() {
65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
66 context_.reset(new BlobStorageContext()); 66 context_.reset(new BlobStorageContext());
67 } 67 }
68 68
69 scoped_ptr<BlobHandle> ChromeBlobStorageContext::CreateMemoryBackedBlob( 69 scoped_ptr<BlobHandle> ChromeBlobStorageContext::CreateMemoryBackedBlob(
70 const char* data, size_t length) { 70 const char* data, size_t length) {
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
72 72
73 std::string uuid(base::GenerateGUID()); 73 std::string uuid(base::GenerateGUID());
74 scoped_refptr<webkit_blob::BlobData> blob_data = 74 scoped_refptr<storage::BlobData> blob_data = new storage::BlobData(uuid);
75 new webkit_blob::BlobData(uuid);
76 blob_data->AppendData(data, length); 75 blob_data->AppendData(data, length);
77 76
78 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle = 77 scoped_ptr<storage::BlobDataHandle> blob_data_handle =
79 context_->AddFinishedBlob(blob_data.get()); 78 context_->AddFinishedBlob(blob_data.get());
80 if (!blob_data_handle) 79 if (!blob_data_handle)
81 return scoped_ptr<BlobHandle>(); 80 return scoped_ptr<BlobHandle>();
82 81
83 scoped_ptr<BlobHandle> blob_handle( 82 scoped_ptr<BlobHandle> blob_handle(
84 new BlobHandleImpl(blob_data_handle.Pass())); 83 new BlobHandleImpl(blob_data_handle.Pass()));
85 return blob_handle.Pass(); 84 return blob_handle.Pass();
86 } 85 }
87 86
88 ChromeBlobStorageContext::~ChromeBlobStorageContext() {} 87 ChromeBlobStorageContext::~ChromeBlobStorageContext() {}
89 88
90 void ChromeBlobStorageContext::DeleteOnCorrectThread() const { 89 void ChromeBlobStorageContext::DeleteOnCorrectThread() const {
91 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && 90 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) &&
92 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { 91 !BrowserThread::CurrentlyOn(BrowserThread::IO)) {
93 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); 92 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this);
94 return; 93 return;
95 } 94 }
96 delete this; 95 delete this;
97 } 96 }
98 97
99 } // namespace content 98 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/fileapi/chrome_blob_storage_context.h ('k') | content/browser/fileapi/copy_or_move_file_validator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698