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

Side by Side Diff: chrome/browser/extensions/blob_holder.cc

Issue 266373006: Blobs: Mechanism for creating Blobs in browser process, then transferring to renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
OLDNEW
(Empty)
1 // Copyright 2014 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 "chrome/browser/extensions/blob_holder.h"
6
7 #include "base/logging.h"
8 #include "content/public/browser/blob_context.h"
9 #include "extensions/common/extension_messages.h"
10
11 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::BlobHolder);
12
13 namespace extensions {
14
15 BlobHolder::~BlobHolder() {
16 }
17
18 void BlobHolder::HoldBlobReference(scoped_ptr<content::BlobHandle> blob) {
19 held_blobs_.push_back(blob.release());
20 }
21
22 BlobHolder::BlobHolder(content::WebContents* web_contents)
23 : content::WebContentsObserver(web_contents) {
24 }
25
26 bool BlobHolder::OnMessageReceived(const IPC::Message& message) {
27 bool handled = true;
28 IPC_BEGIN_MESSAGE_MAP(BlobHolder, message)
29 IPC_MESSAGE_HANDLER(ExtensionHostMsg_BlobOwnershipTaken,
30 OnBlobOwnershipTaken)
31 IPC_MESSAGE_UNHANDLED(handled = false)
32 IPC_END_MESSAGE_MAP()
33 return handled;
34 }
35
36 void BlobHolder::OnBlobOwnershipTaken(const std::string& uuid) {
37 for (ScopedVector<content::BlobHandle>::iterator it = held_blobs_.begin();
38 it != held_blobs_.end(); ++it) {
39 if ((*it)->uuid() == uuid) {
40 it = held_blobs_.erase(it);
41 return;
42 }
43 }
44 DLOG(ERROR) << "Tried to release a Blob we don't have ownership to. UUID: "
45 << uuid;
46 }
47
48 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698