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 base { |
| 14 class FilePath; |
| 15 class Time; |
| 16 } |
| 17 |
13 namespace storage { | 18 namespace storage { |
14 class BlobStorageContext; | 19 class BlobStorageContext; |
15 } | 20 } |
16 | 21 |
17 namespace content { | 22 namespace content { |
18 class BlobHandle; | 23 class BlobHandle; |
19 class BrowserContext; | 24 class BrowserContext; |
20 struct ChromeBlobStorageContextDeleter; | 25 struct ChromeBlobStorageContextDeleter; |
21 | 26 |
22 // A context class that keeps track of BlobStorageController used by the chrome. | 27 // A context class that keeps track of BlobStorageController used by the chrome. |
(...skipping 13 matching lines...) Expand all Loading... |
36 BrowserContext* browser_context); | 41 BrowserContext* browser_context); |
37 | 42 |
38 void InitializeOnIOThread(); | 43 void InitializeOnIOThread(); |
39 | 44 |
40 storage::BlobStorageContext* context() const { return context_.get(); } | 45 storage::BlobStorageContext* context() const { return context_.get(); } |
41 | 46 |
42 // Returns a NULL scoped_ptr on failure. | 47 // Returns a NULL scoped_ptr on failure. |
43 scoped_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data, | 48 scoped_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data, |
44 size_t length); | 49 size_t length); |
45 | 50 |
| 51 // Returns a NULL scoped_ptr on failure. |
| 52 scoped_ptr<BlobHandle> CreateFileBackedBlob( |
| 53 const base::FilePath& path, |
| 54 int64_t offset, |
| 55 int64_t size, |
| 56 const base::Time& expected_modification_time); |
| 57 |
46 protected: | 58 protected: |
47 virtual ~ChromeBlobStorageContext(); | 59 virtual ~ChromeBlobStorageContext(); |
48 | 60 |
49 private: | 61 private: |
50 friend class base::DeleteHelper<ChromeBlobStorageContext>; | 62 friend class base::DeleteHelper<ChromeBlobStorageContext>; |
51 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext, | 63 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext, |
52 ChromeBlobStorageContextDeleter>; | 64 ChromeBlobStorageContextDeleter>; |
53 friend struct ChromeBlobStorageContextDeleter; | 65 friend struct ChromeBlobStorageContextDeleter; |
54 | 66 |
55 void DeleteOnCorrectThread() const; | 67 void DeleteOnCorrectThread() const; |
56 | 68 |
57 scoped_ptr<storage::BlobStorageContext> context_; | 69 scoped_ptr<storage::BlobStorageContext> context_; |
58 }; | 70 }; |
59 | 71 |
60 struct ChromeBlobStorageContextDeleter { | 72 struct ChromeBlobStorageContextDeleter { |
61 static void Destruct(const ChromeBlobStorageContext* context) { | 73 static void Destruct(const ChromeBlobStorageContext* context) { |
62 context->DeleteOnCorrectThread(); | 74 context->DeleteOnCorrectThread(); |
63 } | 75 } |
64 }; | 76 }; |
65 | 77 |
66 } // namespace content | 78 } // namespace content |
67 | 79 |
68 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ | 80 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ |
OLD | NEW |