OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_CHROME_BLOB_STORAGE_CONTEXT_H_ | |
6 #define CONTENT_BROWSER_CHROME_BLOB_STORAGE_CONTEXT_H_ | |
7 #pragma once | |
8 | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/message_loop_helpers.h" | |
12 #include "content/common/content_export.h" | |
13 #include "content/public/browser/browser_thread.h" | |
14 | |
15 namespace content { | |
16 class BrowserContext; | |
17 } | |
18 | |
19 namespace webkit_blob { | |
20 class BlobStorageController; | |
21 } | |
22 | |
23 struct ChromeBlobStorageContextDeleter; | |
24 | |
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 | |
27 // multiple URLRequestContexts in the same browser context that refers to the | |
28 // same instance. | |
29 // | |
30 // All methods, except the ctor, are expected to be called on | |
31 // the IO thread (unless specifically called out in doc comments). | |
32 class CONTENT_EXPORT ChromeBlobStorageContext | |
33 : public base::RefCountedThreadSafe< | |
34 ChromeBlobStorageContext, ChromeBlobStorageContextDeleter> { | |
35 public: | |
36 static ChromeBlobStorageContext* GetFor( | |
37 content::BrowserContext* browser_context); | |
38 | |
39 ChromeBlobStorageContext(); | |
40 virtual ~ChromeBlobStorageContext(); | |
41 | |
42 void InitializeOnIOThread(); | |
43 | |
44 webkit_blob::BlobStorageController* controller() const { | |
45 return controller_.get(); | |
46 } | |
47 | |
48 private: | |
49 friend struct ChromeBlobStorageContextDeleter; | |
50 | |
51 void DeleteOnCorrectThread() const; | |
52 | |
53 scoped_ptr<webkit_blob::BlobStorageController> controller_; | |
54 }; | |
55 | |
56 struct ChromeBlobStorageContextDeleter { | |
57 static void Destruct(const ChromeBlobStorageContext* context) { | |
58 context->DeleteOnCorrectThread(); | |
59 } | |
60 }; | |
61 | |
62 #endif // CONTENT_BROWSER_CHROME_BLOB_STORAGE_CONTEXT_H_ | |
OLD | NEW |