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

Side by Side 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, 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 | Annotate | Revision Log
« no previous file with comments | « webkit/blob/blob_data_handle.h ('k') | webkit/blob/blob_storage_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 #include "webkit/blob/blob_data_handle.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/logging.h"
10 #include "base/sequenced_task_runner.h"
11 #include "webkit/blob/blob_data.h"
12 #include "webkit/blob/blob_storage_context.h"
13
14 namespace webkit_blob {
15
16 BlobDataHandle::BlobDataHandle(BlobData* blob_data, BlobStorageContext* context,
17 base::SequencedTaskRunner* task_runner)
18 : blob_data_(blob_data),
19 context_(context->AsWeakPtr()),
20 io_task_runner_(task_runner) {
21 // Ensures the uuid remains registered and the underlying data is not deleted.
22 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
23 context_->IncrementBlobRefCount(blob_data->uuid());
24 blob_data_->AddRef();
25 }
26
27 BlobDataHandle::~BlobDataHandle() {
28 if (io_task_runner_->RunsTasksOnCurrentThread()) {
29 // Note: Do not test context_ or alter the blob_data_ refcount
30 // on the wrong thread.
31 if (context_.get())
32 context_->DecrementBlobRefCount(blob_data_->uuid());
33 blob_data_->Release();
34 return;
35 }
36
37 io_task_runner_->PostTask(
38 FROM_HERE,
39 base::Bind(&DeleteHelper, context_, base::Unretained(blob_data_)));
40 }
41
42 BlobData* BlobDataHandle::data() const {
43 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
44 return blob_data_;
45 }
46
47 // static
48 void BlobDataHandle::DeleteHelper(
49 base::WeakPtr<BlobStorageContext> context,
50 BlobData* blob_data) {
51 if (context.get())
52 context->DecrementBlobRefCount(blob_data->uuid());
53 blob_data->Release();
54 }
55
56 } // namespace webkit_blob
OLDNEW
« 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