| 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" |
| 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 webkit_blob::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"; |
| 23 |
| 22 class BlobHandleImpl : public BlobHandle { | 24 class BlobHandleImpl : public BlobHandle { |
| 23 public: | 25 public: |
| 24 BlobHandleImpl(scoped_ptr<webkit_blob::BlobDataHandle> handle) | 26 explicit BlobHandleImpl(scoped_ptr<webkit_blob::BlobDataHandle> handle) |
| 25 : handle_(handle.Pass()) { | 27 : handle_(handle.Pass()) { |
| 26 } | 28 } |
| 27 | 29 |
| 28 virtual ~BlobHandleImpl() {} | 30 virtual ~BlobHandleImpl() {} |
| 29 | 31 |
| 30 virtual std::string GetUUID() OVERRIDE { | 32 virtual std::string GetUUID() OVERRIDE { |
| 31 return handle_->uuid(); | 33 return handle_->uuid(); |
| 32 } | 34 } |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 scoped_ptr<webkit_blob::BlobDataHandle> handle_; | 37 scoped_ptr<webkit_blob::BlobDataHandle> handle_; |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 } // namespace | 40 } // namespace |
| 39 | 41 |
| 40 static const char* kBlobStorageContextKeyName = "content_blob_storage_context"; | |
| 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 = |
| 48 new ChromeBlobStorageContext(); | 48 new ChromeBlobStorageContext(); |
| 49 context->SetUserData( | 49 context->SetUserData( |
| 50 kBlobStorageContextKeyName, | 50 kBlobStorageContextKeyName, |
| 51 new UserDataAdapter<ChromeBlobStorageContext>(blob.get())); | 51 new UserDataAdapter<ChromeBlobStorageContext>(blob.get())); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 void ChromeBlobStorageContext::DeleteOnCorrectThread() const { | 90 void ChromeBlobStorageContext::DeleteOnCorrectThread() const { |
| 91 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && | 91 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && |
| 92 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 92 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 93 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 93 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 delete this; | 96 delete this; |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace content | 99 } // namespace content |
| OLD | NEW |