OLD | NEW |
(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 #ifndef EXTENSIONS_BROWSER_BLOB_HOLDER_H_ |
| 6 #define EXTENSIONS_BROWSER_BLOB_HOLDER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/supports_user_data.h" |
| 11 |
| 12 namespace content { |
| 13 class BlobHandle; |
| 14 class RenderProcessHost; |
| 15 } |
| 16 |
| 17 namespace extensions { |
| 18 |
| 19 class ExtensionMessageFilter; |
| 20 |
| 21 // Used for holding onto Blobs created into the browser process until a |
| 22 // renderer takes over ownership. This class operates on the UI thread. |
| 23 class BlobHolder : public base::SupportsUserData::Data { |
| 24 public: |
| 25 // Will create the BlobHolder if it doesn't already exist. |
| 26 static BlobHolder* FromRenderProcessHost( |
| 27 content::RenderProcessHost* render_process_host); |
| 28 |
| 29 virtual ~BlobHolder(); |
| 30 |
| 31 // Causes BlobHolder to take ownership of |blob|. |
| 32 void HoldBlobReference(scoped_ptr<content::BlobHandle> blob); |
| 33 |
| 34 private: |
| 35 typedef ScopedVector<content::BlobHandle> BlobHandleVector; |
| 36 |
| 37 explicit BlobHolder(content::RenderProcessHost* render_process_host); |
| 38 |
| 39 // BlobHolder will drop a blob handle for each element in blob_uuids. |
| 40 // If caller wishes to drop multiple references to the same blob, |
| 41 // |blob_uuids| may contain duplicate UUIDs. |
| 42 void DropBlobs(const std::vector<std::string>& blob_uuids); |
| 43 friend class ExtensionMessageFilter; |
| 44 |
| 45 bool ContainsBlobHandle(content::BlobHandle* handle) const; |
| 46 |
| 47 // A reference to the owner of this class. |
| 48 content::RenderProcessHost* render_process_host_; |
| 49 |
| 50 BlobHandleVector held_blobs_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(BlobHolder); |
| 53 }; |
| 54 |
| 55 } // namespace extensions |
| 56 |
| 57 #endif // EXTENSIONS_BROWSER_BLOB_HOLDER_H_ |
OLD | NEW |