| 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 #ifndef CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ |
| 6 #define CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ | 6 #define CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/sequenced_task_runner_helpers.h" | 10 #include "base/sequenced_task_runner_helpers.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // There is an instance associated with each BrowserContext. There could be | 28 // There is an instance associated with each BrowserContext. There could be |
| 29 // multiple URLRequestContexts in the same browser context that refers to the | 29 // multiple URLRequestContexts in the same browser context that refers to the |
| 30 // same instance. | 30 // same instance. |
| 31 // | 31 // |
| 32 // All methods, except the ctor, are expected to be called on | 32 // All methods, except the ctor, are expected to be called on |
| 33 // the IO thread (unless specifically called out in doc comments). | 33 // the IO thread (unless specifically called out in doc comments). |
| 34 class CONTENT_EXPORT ChromeBlobStorageContext | 34 class CONTENT_EXPORT ChromeBlobStorageContext |
| 35 : public base::RefCountedThreadSafe<ChromeBlobStorageContext, | 35 : public base::RefCountedThreadSafe<ChromeBlobStorageContext, |
| 36 ChromeBlobStorageContextDeleter> { | 36 ChromeBlobStorageContextDeleter> { |
| 37 public: | 37 public: |
| 38 ChromeBlobStorageContext(); | 38 explicit ChromeBlobStorageContext(bool disk_enabled); |
| 39 | 39 |
| 40 static ChromeBlobStorageContext* GetFor( | 40 static ChromeBlobStorageContext* GetFor( |
| 41 BrowserContext* browser_context); | 41 BrowserContext* browser_context); |
| 42 | 42 |
| 43 void InitializeOnIOThread(); | 43 void InitializeOnIOThread(); |
| 44 | 44 |
| 45 storage::BlobStorageContext* context() const { return context_.get(); } | 45 storage::BlobStorageContext* context() const { return context_.get(); } |
| 46 | 46 |
| 47 // Returns a NULL scoped_ptr on failure. | 47 // Returns a NULL scoped_ptr on failure. |
| 48 scoped_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data, | 48 scoped_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 59 virtual ~ChromeBlobStorageContext(); | 59 virtual ~ChromeBlobStorageContext(); |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 friend class base::DeleteHelper<ChromeBlobStorageContext>; | 62 friend class base::DeleteHelper<ChromeBlobStorageContext>; |
| 63 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext, | 63 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext, |
| 64 ChromeBlobStorageContextDeleter>; | 64 ChromeBlobStorageContextDeleter>; |
| 65 friend struct ChromeBlobStorageContextDeleter; | 65 friend struct ChromeBlobStorageContextDeleter; |
| 66 | 66 |
| 67 void DeleteOnCorrectThread() const; | 67 void DeleteOnCorrectThread() const; |
| 68 | 68 |
| 69 bool disk_enabled_; |
| 69 scoped_ptr<storage::BlobStorageContext> context_; | 70 scoped_ptr<storage::BlobStorageContext> context_; |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 struct ChromeBlobStorageContextDeleter { | 73 struct ChromeBlobStorageContextDeleter { |
| 73 static void Destruct(const ChromeBlobStorageContext* context) { | 74 static void Destruct(const ChromeBlobStorageContext* context) { |
| 74 context->DeleteOnCorrectThread(); | 75 context->DeleteOnCorrectThread(); |
| 75 } | 76 } |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace content | 79 } // namespace content |
| 79 | 80 |
| 80 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ | 81 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ |
| OLD | NEW |