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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
| 13 #include "base/files/file_path.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/sequenced_task_runner_helpers.h" | 15 #include "base/sequenced_task_runner_helpers.h" |
15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class FilePath; | 19 class FilePath; |
| 20 class TaskRunner; |
19 class Time; | 21 class Time; |
20 } | 22 } |
21 | 23 |
22 namespace storage { | 24 namespace storage { |
23 class BlobStorageContext; | 25 class BlobStorageContext; |
24 } | 26 } |
25 | 27 |
26 namespace content { | 28 namespace content { |
27 class BlobHandle; | 29 class BlobHandle; |
28 class BrowserContext; | 30 class BrowserContext; |
29 struct ChromeBlobStorageContextDeleter; | 31 struct ChromeBlobStorageContextDeleter; |
30 | 32 |
31 // A context class that keeps track of BlobStorageController used by the chrome. | 33 // A context class that keeps track of BlobStorageController used by the chrome. |
32 // There is an instance associated with each BrowserContext. There could be | 34 // There is an instance associated with each BrowserContext. There could be |
33 // multiple URLRequestContexts in the same browser context that refers to the | 35 // multiple URLRequestContexts in the same browser context that refers to the |
34 // same instance. | 36 // same instance. |
35 // | 37 // |
36 // All methods, except the ctor, are expected to be called on | 38 // All methods, except the ctor, are expected to be called on |
37 // the IO thread (unless specifically called out in doc comments). | 39 // the IO thread (unless specifically called out in doc comments). |
38 class CONTENT_EXPORT ChromeBlobStorageContext | 40 class CONTENT_EXPORT ChromeBlobStorageContext |
39 : public base::RefCountedThreadSafe<ChromeBlobStorageContext, | 41 : public base::RefCountedThreadSafe<ChromeBlobStorageContext, |
40 ChromeBlobStorageContextDeleter> { | 42 ChromeBlobStorageContextDeleter> { |
41 public: | 43 public: |
42 ChromeBlobStorageContext(); | 44 ChromeBlobStorageContext(); |
43 | 45 |
44 static ChromeBlobStorageContext* GetFor( | 46 static ChromeBlobStorageContext* GetFor( |
45 BrowserContext* browser_context); | 47 BrowserContext* browser_context); |
46 | 48 |
47 void InitializeOnIOThread(); | 49 void InitializeOnIOThread(base::FilePath blob_storage_dir, |
| 50 scoped_refptr<base::TaskRunner> file_task_runner); |
48 | 51 |
49 storage::BlobStorageContext* context() const { return context_.get(); } | 52 storage::BlobStorageContext* context() const { return context_.get(); } |
50 | 53 |
51 // Returns a NULL scoped_ptr on failure. | 54 // Returns a NULL scoped_ptr on failure. |
52 std::unique_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data, | 55 std::unique_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data, |
53 size_t length); | 56 size_t length); |
54 | 57 |
55 // Returns a NULL scoped_ptr on failure. | 58 // Returns a NULL scoped_ptr on failure. |
56 std::unique_ptr<BlobHandle> CreateFileBackedBlob( | 59 std::unique_ptr<BlobHandle> CreateFileBackedBlob( |
57 const base::FilePath& path, | 60 const base::FilePath& path, |
(...skipping 17 matching lines...) Expand all Loading... |
75 | 78 |
76 struct ChromeBlobStorageContextDeleter { | 79 struct ChromeBlobStorageContextDeleter { |
77 static void Destruct(const ChromeBlobStorageContext* context) { | 80 static void Destruct(const ChromeBlobStorageContext* context) { |
78 context->DeleteOnCorrectThread(); | 81 context->DeleteOnCorrectThread(); |
79 } | 82 } |
80 }; | 83 }; |
81 | 84 |
82 } // namespace content | 85 } // namespace content |
83 | 86 |
84 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ | 87 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ |
OLD | NEW |