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

Unified Diff: webkit/blob/blob_data_handle.cc

Issue 14139026: New blobstoragecontext for use in the main browser process, not plugged in yet. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/blob/blob_data_handle.h ('k') | webkit/blob/blob_storage_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/blob/blob_data_handle.cc
===================================================================
--- webkit/blob/blob_data_handle.cc (revision 0)
+++ webkit/blob/blob_data_handle.cc (revision 0)
@@ -0,0 +1,56 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/blob/blob_data_handle.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/logging.h"
+#include "base/sequenced_task_runner.h"
+#include "webkit/blob/blob_data.h"
+#include "webkit/blob/blob_storage_context.h"
+
+namespace webkit_blob {
+
+BlobDataHandle::BlobDataHandle(BlobData* blob_data, BlobStorageContext* context,
+ base::SequencedTaskRunner* task_runner)
+ : blob_data_(blob_data),
+ context_(context->AsWeakPtr()),
+ io_task_runner_(task_runner) {
+ // Ensures the uuid remains registered and the underlying data is not deleted.
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
+ context_->IncrementBlobRefCount(blob_data->uuid());
+ blob_data_->AddRef();
+}
+
+BlobDataHandle::~BlobDataHandle() {
+ if (io_task_runner_->RunsTasksOnCurrentThread()) {
+ // Note: Do not test context_ or alter the blob_data_ refcount
+ // on the wrong thread.
+ if (context_.get())
+ context_->DecrementBlobRefCount(blob_data_->uuid());
+ blob_data_->Release();
+ return;
+ }
+
+ io_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&DeleteHelper, context_, base::Unretained(blob_data_)));
+}
+
+BlobData* BlobDataHandle::data() const {
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
+ return blob_data_;
+}
+
+// static
+void BlobDataHandle::DeleteHelper(
+ base::WeakPtr<BlobStorageContext> context,
+ BlobData* blob_data) {
+ if (context.get())
+ context->DecrementBlobRefCount(blob_data->uuid());
+ blob_data->Release();
+}
+
+} // namespace webkit_blob
Property changes on: webkit\blob\blob_data_handle.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « webkit/blob/blob_data_handle.h ('k') | webkit/blob/blob_storage_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698