summaryrefslogtreecommitdiffstats
path: root/chromium/content/browser/fileapi/chrome_blob_storage_context.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/browser/fileapi/chrome_blob_storage_context.cc')
-rw-r--r--chromium/content/browser/fileapi/chrome_blob_storage_context.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/chromium/content/browser/fileapi/chrome_blob_storage_context.cc b/chromium/content/browser/fileapi/chrome_blob_storage_context.cc
index 97151a83f67..fce0bed9066 100644
--- a/chromium/content/browser/fileapi/chrome_blob_storage_context.cc
+++ b/chromium/content/browser/fileapi/chrome_blob_storage_context.cc
@@ -5,8 +5,11 @@
#include "content/browser/fileapi/chrome_blob_storage_context.h"
#include "base/bind.h"
+#include "base/guid.h"
+#include "content/public/browser/blob_handle.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
+#include "webkit/browser/blob/blob_data_handle.h"
#include "webkit/browser/blob/blob_storage_context.h"
using base::UserDataAdapter;
@@ -14,6 +17,26 @@ using webkit_blob::BlobStorageContext;
namespace content {
+namespace {
+
+class BlobHandleImpl : public BlobHandle {
+ public:
+ BlobHandleImpl(scoped_ptr<webkit_blob::BlobDataHandle> handle)
+ : handle_(handle.Pass()) {
+ }
+
+ virtual ~BlobHandleImpl() {}
+
+ virtual std::string GetUUID() OVERRIDE {
+ return handle_->uuid();
+ }
+
+ private:
+ scoped_ptr<webkit_blob::BlobDataHandle> handle_;
+};
+
+} // namespace
+
static const char* kBlobStorageContextKeyName = "content_blob_storage_context";
ChromeBlobStorageContext::ChromeBlobStorageContext() {}
@@ -43,6 +66,25 @@ void ChromeBlobStorageContext::InitializeOnIOThread() {
context_.reset(new BlobStorageContext());
}
+scoped_ptr<BlobHandle> ChromeBlobStorageContext::CreateMemoryBackedBlob(
+ const char* data, size_t length) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ std::string uuid(base::GenerateGUID());
+ scoped_refptr<webkit_blob::BlobData> blob_data =
+ new webkit_blob::BlobData(uuid);
+ blob_data->AppendData(data, length);
+
+ scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle =
+ context_->AddFinishedBlob(blob_data.get());
+ if (!blob_data_handle)
+ return scoped_ptr<BlobHandle>();
+
+ scoped_ptr<BlobHandle> blob_handle(
+ new BlobHandleImpl(blob_data_handle.Pass()));
+ return blob_handle.Pass();
+}
+
ChromeBlobStorageContext::~ChromeBlobStorageContext() {}
void ChromeBlobStorageContext::DeleteOnCorrectThread() const {