OLD | NEW |
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" |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 BlobHolder::~BlobHolder() { | 39 BlobHolder::~BlobHolder() { |
40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
41 } | 41 } |
42 | 42 |
43 void BlobHolder::HoldBlobReference(scoped_ptr<content::BlobHandle> blob) { | 43 void BlobHolder::HoldBlobReference(scoped_ptr<content::BlobHandle> blob) { |
44 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 44 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
45 DCHECK(!ContainsBlobHandle(blob.get())); | 45 DCHECK(!ContainsBlobHandle(blob.get())); |
46 | 46 |
47 held_blobs_.insert( | 47 std::string uuid = blob->GetUUID(); |
48 make_pair(blob->GetUUID(), make_linked_ptr(blob.release()))); | 48 held_blobs_.insert(make_pair(uuid, make_linked_ptr(blob.release()))); |
49 } | 49 } |
50 | 50 |
51 BlobHolder::BlobHolder(content::RenderProcessHost* render_process_host) | 51 BlobHolder::BlobHolder(content::RenderProcessHost* render_process_host) |
52 : render_process_host_(render_process_host) { | 52 : render_process_host_(render_process_host) { |
53 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 53 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
54 } | 54 } |
55 | 55 |
56 bool BlobHolder::ContainsBlobHandle(content::BlobHandle* handle) const { | 56 bool BlobHolder::ContainsBlobHandle(content::BlobHandle* handle) const { |
57 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 57 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
58 for (BlobHandleMultimap::const_iterator it = held_blobs_.begin(); | 58 for (BlobHandleMultimap::const_iterator it = held_blobs_.begin(); |
(...skipping 17 matching lines...) Expand all Loading... |
76 held_blobs_.erase(it); | 76 held_blobs_.erase(it); |
77 } else { | 77 } else { |
78 DLOG(ERROR) << "Tried to release a Blob we don't have ownership to." | 78 DLOG(ERROR) << "Tried to release a Blob we don't have ownership to." |
79 << "UUID: " << *uuid_it; | 79 << "UUID: " << *uuid_it; |
80 render_process_host_->ReceivedBadMessage(); | 80 render_process_host_->ReceivedBadMessage(); |
81 } | 81 } |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 } // namespace extensions | 85 } // namespace extensions |
OLD | NEW |