Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: content/browser/blob_storage/chrome_blob_storage_context.h

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes, working w/ Layout tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
19 class Time; 20 class Time;
20 } 21 }
21 22
22 namespace storage { 23 namespace storage {
23 class BlobStorageContext; 24 class BlobStorageContext;
24 } 25 }
25 26
26 namespace content { 27 namespace content {
27 class BlobHandle; 28 class BlobHandle;
28 class BrowserContext; 29 class BrowserContext;
29 struct ChromeBlobStorageContextDeleter; 30 struct ChromeBlobStorageContextDeleter;
30 31
31 // A context class that keeps track of BlobStorageController used by the chrome. 32 // A context class that keeps track of BlobStorageController used by the chrome.
32 // There is an instance associated with each BrowserContext. There could be 33 // There is an instance associated with each BrowserContext. There could be
33 // multiple URLRequestContexts in the same browser context that refers to the 34 // multiple URLRequestContexts in the same browser context that refers to the
34 // same instance. 35 // same instance.
35 // 36 //
36 // All methods, except the ctor, are expected to be called on 37 // All methods, except the ctor, are expected to be called on
37 // the IO thread (unless specifically called out in doc comments). 38 // the IO thread (unless specifically called out in doc comments).
38 class CONTENT_EXPORT ChromeBlobStorageContext 39 class CONTENT_EXPORT ChromeBlobStorageContext
39 : public base::RefCountedThreadSafe<ChromeBlobStorageContext, 40 : public base::RefCountedThreadSafe<ChromeBlobStorageContext,
40 ChromeBlobStorageContextDeleter> { 41 ChromeBlobStorageContextDeleter> {
41 public: 42 public:
42 ChromeBlobStorageContext(); 43 explicit ChromeBlobStorageContext();
43 44
44 static ChromeBlobStorageContext* GetFor( 45 static ChromeBlobStorageContext* GetFor(
45 BrowserContext* browser_context); 46 BrowserContext* browser_context);
46 47
47 void InitializeOnIOThread(); 48 void InitializeOnIOThread();
48 49
49 storage::BlobStorageContext* context() const { return context_.get(); } 50 storage::BlobStorageContext* context() const { return context_.get(); }
50 51
51 // Returns a NULL scoped_ptr on failure. 52 // Returns a NULL scoped_ptr on failure.
52 std::unique_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data, 53 std::unique_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data,
(...skipping 10 matching lines...) Expand all
63 virtual ~ChromeBlobStorageContext(); 64 virtual ~ChromeBlobStorageContext();
64 65
65 private: 66 private:
66 friend class base::DeleteHelper<ChromeBlobStorageContext>; 67 friend class base::DeleteHelper<ChromeBlobStorageContext>;
67 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext, 68 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext,
68 ChromeBlobStorageContextDeleter>; 69 ChromeBlobStorageContextDeleter>;
69 friend struct ChromeBlobStorageContextDeleter; 70 friend struct ChromeBlobStorageContextDeleter;
70 71
71 void DeleteOnCorrectThread() const; 72 void DeleteOnCorrectThread() const;
72 73
74 // Called after successfully creating our blob directory. This enables disk
75 // usage on |context_|.
76 void OnBlobDirectoryCreated(const base::FilePath& blob_storage_directory);
77
78 base::FilePath blob_storage_dir_;
73 std::unique_ptr<storage::BlobStorageContext> context_; 79 std::unique_ptr<storage::BlobStorageContext> context_;
74 }; 80 };
75 81
76 struct ChromeBlobStorageContextDeleter { 82 struct ChromeBlobStorageContextDeleter {
77 static void Destruct(const ChromeBlobStorageContext* context) { 83 static void Destruct(const ChromeBlobStorageContext* context) {
78 context->DeleteOnCorrectThread(); 84 context->DeleteOnCorrectThread();
79 } 85 }
80 }; 86 };
81 87
82 } // namespace content 88 } // namespace content
83 89
84 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_ 90 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698