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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 struct ChromeBlobStorageContextDeleter; | 23 struct ChromeBlobStorageContextDeleter; |
24 | 24 |
25 // A context class that keeps track of BlobStorageController used by the chrome. | 25 // A context class that keeps track of BlobStorageController used by the chrome. |
26 // There is an instance associated with each BrowserContext. There could be | 26 // There is an instance associated with each BrowserContext. There could be |
27 // multiple URLRequestContexts in the same browser context that refers to the | 27 // multiple URLRequestContexts in the same browser context that refers to the |
28 // same instance. | 28 // same instance. |
29 // | 29 // |
30 // All methods, except the ctor, are expected to be called on | 30 // All methods, except the ctor, are expected to be called on |
31 // the IO thread (unless specifically called out in doc comments). | 31 // the IO thread (unless specifically called out in doc comments). |
32 class CONTENT_EXPORT ChromeBlobStorageContext | 32 class CONTENT_EXPORT ChromeBlobStorageContext |
33 : public base::RefCountedThreadSafe< | 33 : public base::RefCountedThreadSafe<ChromeBlobStorageContext, |
34 ChromeBlobStorageContext, ChromeBlobStorageContextDeleter> { | 34 ChromeBlobStorageContextDeleter> { |
35 public: | 35 public: |
| 36 ChromeBlobStorageContext(); |
| 37 |
36 static ChromeBlobStorageContext* GetFor( | 38 static ChromeBlobStorageContext* GetFor( |
37 content::BrowserContext* browser_context); | 39 content::BrowserContext* browser_context); |
38 | 40 |
39 ChromeBlobStorageContext(); | |
40 virtual ~ChromeBlobStorageContext(); | |
41 | |
42 void InitializeOnIOThread(); | 41 void InitializeOnIOThread(); |
43 | 42 |
44 webkit_blob::BlobStorageController* controller() const { | 43 webkit_blob::BlobStorageController* controller() const { |
45 return controller_.get(); | 44 return controller_.get(); |
46 } | 45 } |
47 | 46 |
| 47 protected: |
| 48 virtual ~ChromeBlobStorageContext(); |
| 49 |
48 private: | 50 private: |
| 51 friend class base::DeleteHelper<ChromeBlobStorageContext>; |
| 52 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext, |
| 53 ChromeBlobStorageContextDeleter>; |
49 friend struct ChromeBlobStorageContextDeleter; | 54 friend struct ChromeBlobStorageContextDeleter; |
50 | 55 |
51 void DeleteOnCorrectThread() const; | 56 void DeleteOnCorrectThread() const; |
52 | 57 |
53 scoped_ptr<webkit_blob::BlobStorageController> controller_; | 58 scoped_ptr<webkit_blob::BlobStorageController> controller_; |
54 }; | 59 }; |
55 | 60 |
56 struct ChromeBlobStorageContextDeleter { | 61 struct ChromeBlobStorageContextDeleter { |
57 static void Destruct(const ChromeBlobStorageContext* context) { | 62 static void Destruct(const ChromeBlobStorageContext* context) { |
58 context->DeleteOnCorrectThread(); | 63 context->DeleteOnCorrectThread(); |
59 } | 64 } |
60 }; | 65 }; |
61 | 66 |
62 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ | 67 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ |
OLD | NEW |