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