Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / fileapi / chrome_blob_storage_context.h
blob0c565459a2cf052e2e159132e972025fbe7fed73
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.
5 #ifndef CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_
6 #define CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/sequenced_task_runner_helpers.h"
11 #include "content/common/content_export.h"
13 namespace base {
14 class FilePath;
15 class Time;
18 namespace storage {
19 class BlobStorageContext;
22 namespace content {
23 class BlobHandle;
24 class BrowserContext;
25 struct ChromeBlobStorageContextDeleter;
27 // A context class that keeps track of BlobStorageController used by the chrome.
28 // There is an instance associated with each BrowserContext. There could be
29 // multiple URLRequestContexts in the same browser context that refers to the
30 // same instance.
32 // All methods, except the ctor, are expected to be called on
33 // the IO thread (unless specifically called out in doc comments).
34 class CONTENT_EXPORT ChromeBlobStorageContext
35 : public base::RefCountedThreadSafe<ChromeBlobStorageContext,
36 ChromeBlobStorageContextDeleter> {
37 public:
38 ChromeBlobStorageContext();
40 static ChromeBlobStorageContext* GetFor(
41 BrowserContext* browser_context);
43 void InitializeOnIOThread();
45 storage::BlobStorageContext* context() const { return context_.get(); }
47 // Returns a NULL scoped_ptr on failure.
48 scoped_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data,
49 size_t length);
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);
58 protected:
59 virtual ~ChromeBlobStorageContext();
61 private:
62 friend class base::DeleteHelper<ChromeBlobStorageContext>;
63 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext,
64 ChromeBlobStorageContextDeleter>;
65 friend struct ChromeBlobStorageContextDeleter;
67 void DeleteOnCorrectThread() const;
69 scoped_ptr<storage::BlobStorageContext> context_;
72 struct ChromeBlobStorageContextDeleter {
73 static void Destruct(const ChromeBlobStorageContext* context) {
74 context->DeleteOnCorrectThread();
78 } // namespace content
80 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_