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