Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / browser / fileapi / chrome_blob_storage_context.h
blob8d8a5f226b47b4507f79b023645498597cf98e03
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 storage {
14 class BlobStorageContext;
17 namespace content {
18 class BlobHandle;
19 class BrowserContext;
20 struct ChromeBlobStorageContextDeleter;
22 // A context class that keeps track of BlobStorageController used by the chrome.
23 // There is an instance associated with each BrowserContext. There could be
24 // multiple URLRequestContexts in the same browser context that refers to the
25 // same instance.
27 // All methods, except the ctor, are expected to be called on
28 // the IO thread (unless specifically called out in doc comments).
29 class CONTENT_EXPORT ChromeBlobStorageContext
30 : public base::RefCountedThreadSafe<ChromeBlobStorageContext,
31 ChromeBlobStorageContextDeleter> {
32 public:
33 ChromeBlobStorageContext();
35 static ChromeBlobStorageContext* GetFor(
36 BrowserContext* browser_context);
38 void InitializeOnIOThread();
40 storage::BlobStorageContext* context() const { return context_.get(); }
42 // Returns a NULL scoped_ptr on failure.
43 scoped_ptr<BlobHandle> CreateMemoryBackedBlob(const char* data,
44 size_t length);
46 protected:
47 virtual ~ChromeBlobStorageContext();
49 private:
50 friend class base::DeleteHelper<ChromeBlobStorageContext>;
51 friend class base::RefCountedThreadSafe<ChromeBlobStorageContext,
52 ChromeBlobStorageContextDeleter>;
53 friend struct ChromeBlobStorageContextDeleter;
55 void DeleteOnCorrectThread() const;
57 scoped_ptr<storage::BlobStorageContext> context_;
60 struct ChromeBlobStorageContextDeleter {
61 static void Destruct(const ChromeBlobStorageContext* context) {
62 context->DeleteOnCorrectThread();
66 } // namespace content
68 #endif // CONTENT_BROWSER_FILEAPI_CHROME_BLOB_STORAGE_CONTEXT_H_