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

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

Issue 1934223004: [BlobStorage] Moving all blob files to applicable directories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_
6 #define CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <memory>
12
13 #include "base/memory/ref_counted.h"
14 #include "base/sequenced_task_runner_helpers.h"
15 #include "content/common/content_export.h"
16
17 namespace base {
18 class FilePath;
19 class Time;
20 }
21
22 namespace storage {
23 class BlobStorageContext;
24 }
25
26 namespace content {
27 class BlobHandle;
28 class BrowserContext;
29 struct ChromeBlobStorageContextDeleter;
30
31 // 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 // multiple URLRequestContexts in the same browser context that refers to the
34 // same instance.
35 //
36 // All methods, except the ctor, are expected to be called on
37 // the IO thread (unless specifically called out in doc comments).
38 class CONTENT_EXPORT ChromeBlobStorageContext
39 : public base::RefCountedThreadSafe<ChromeBlobStorageContext,
40 ChromeBlobStorageContextDeleter> {
41 public:
42 ChromeBlobStorageContext();
43
44 static ChromeBlobStorageContext* GetFor(
45 BrowserContext* browser_context);
46
47 void InitializeOnIOThread();
48
49 storage::BlobStorageContext* context() const { return context_.get(); }
50
51 // Returns a NULL scoped_ptr on failure.
52 std::unique_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data,
53 size_t length);
54
55 // Returns a NULL scoped_ptr on failure.
56 std::unique_ptr<BlobHandle> CreateFileBackedBlob(
57 const base::FilePath& path,
58 int64_t offset,
59 int64_t size,
60 const base::Time& expected_modification_time);
61
62 protected:
63 virtual ~ChromeBlobStorageContext();
64
65 private:
66 friend class base::DeleteHelper<ChromeBlobStorageContext>;
67 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext,
68 ChromeBlobStorageContextDeleter>;
69 friend struct ChromeBlobStorageContextDeleter;
70
71 void DeleteOnCorrectThread() const;
72
73 std::unique_ptr<storage::BlobStorageContext> context_;
74 };
75
76 struct ChromeBlobStorageContextDeleter {
77 static void Destruct(const ChromeBlobStorageContext* context) {
78 context->DeleteOnCorrectThread();
79 }
80 };
81
82 } // namespace content
83
84 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/browser/fileapi/blob_url_request_job_unittest.cc ('k') | content/browser/fileapi/chrome_blob_storage_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698