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