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

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

Issue 2846743002: Switch SupportsUserData uses to use unique_ptr. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | extensions/browser/guest_view/web_view/web_view_content_script_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/blob_holder.h" 5 #include "extensions/browser/blob_holder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h"
11 #include "content/public/browser/blob_handle.h" 12 #include "content/public/browser/blob_handle.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
14 #include "extensions/browser/bad_message.h" 15 #include "extensions/browser/bad_message.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 namespace { 19 namespace {
19 20
20 // Address to this variable used as the user data key. 21 // Address to this variable used as the user data key.
21 const int kBlobHolderUserDataKey = 0; 22 const int kBlobHolderUserDataKey = 0;
22 } 23 }
23 24
24 // static 25 // static
25 BlobHolder* BlobHolder::FromRenderProcessHost( 26 BlobHolder* BlobHolder::FromRenderProcessHost(
26 content::RenderProcessHost* render_process_host) { 27 content::RenderProcessHost* render_process_host) {
27 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
28 DCHECK(render_process_host); 29 DCHECK(render_process_host);
29 BlobHolder* existing = static_cast<BlobHolder*>( 30 BlobHolder* existing = static_cast<BlobHolder*>(
30 render_process_host->GetUserData(&kBlobHolderUserDataKey)); 31 render_process_host->GetUserData(&kBlobHolderUserDataKey));
31 32
32 if (existing) 33 if (existing)
33 return existing; 34 return existing;
34 35
35 BlobHolder* new_instance = new BlobHolder(render_process_host); 36 BlobHolder* new_instance = new BlobHolder(render_process_host);
36 render_process_host->SetUserData(&kBlobHolderUserDataKey, new_instance); 37 render_process_host->SetUserData(&kBlobHolderUserDataKey,
38 base::WrapUnique(new_instance));
37 return new_instance; 39 return new_instance;
38 } 40 }
39 41
40 BlobHolder::~BlobHolder() { 42 BlobHolder::~BlobHolder() {
41 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
42 } 44 }
43 45
44 void BlobHolder::HoldBlobReference(std::unique_ptr<content::BlobHandle> blob) { 46 void BlobHolder::HoldBlobReference(std::unique_ptr<content::BlobHandle> blob) {
45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 47 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
46 DCHECK(!ContainsBlobHandle(blob.get())); 48 DCHECK(!ContainsBlobHandle(blob.get()));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } else { 80 } else {
79 DLOG(ERROR) << "Tried to release a Blob we don't have ownership to." 81 DLOG(ERROR) << "Tried to release a Blob we don't have ownership to."
80 << "UUID: " << *uuid_it; 82 << "UUID: " << *uuid_it;
81 bad_message::ReceivedBadMessage(render_process_host_, 83 bad_message::ReceivedBadMessage(render_process_host_,
82 bad_message::BH_BLOB_NOT_OWNED); 84 bad_message::BH_BLOB_NOT_OWNED);
83 } 85 }
84 } 86 }
85 } 87 }
86 88
87 } // namespace extensions 89 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/guest_view/web_view/web_view_content_script_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698