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

Unified Diff: extensions/browser/blob_holder.h

Issue 280393003: Blobs: Catching browser-process created Blobs in extension code. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | extensions/browser/blob_holder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/blob_holder.h
diff --git a/extensions/browser/blob_holder.h b/extensions/browser/blob_holder.h
new file mode 100644
index 0000000000000000000000000000000000000000..9a1d8f5131e6c776ba2ed508cfa980325b0a4186
--- /dev/null
+++ b/extensions/browser/blob_holder.h
@@ -0,0 +1,62 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_BLOB_HOLDER_H_
+#define EXTENSIONS_BROWSER_BLOB_HOLDER_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/memory/linked_ptr.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/supports_user_data.h"
+
+namespace content {
+class BlobHandle;
+class RenderProcessHost;
+}
+
+namespace extensions {
+
+class ExtensionMessageFilter;
+
+// Used for holding onto Blobs created into the browser process until a
+// renderer takes over ownership. This class operates on the UI thread.
+class BlobHolder : public base::SupportsUserData::Data {
+ public:
+ // Will create the BlobHolder if it doesn't already exist.
+ static BlobHolder* FromRenderProcessHost(
+ content::RenderProcessHost* render_process_host);
+
+ virtual ~BlobHolder();
+
+ // Causes BlobHolder to take ownership of |blob|.
+ void HoldBlobReference(scoped_ptr<content::BlobHandle> blob);
+
+ private:
+ typedef std::multimap<std::string, linked_ptr<content::BlobHandle> >
+ BlobHandleMultimap;
+
+ explicit BlobHolder(content::RenderProcessHost* render_process_host);
+
+ // BlobHolder will drop a blob handle for each element in blob_uuids.
+ // If caller wishes to drop multiple references to the same blob,
+ // |blob_uuids| may contain duplicate UUIDs.
+ void DropBlobs(const std::vector<std::string>& blob_uuids);
+ friend class ExtensionMessageFilter;
+
+ bool ContainsBlobHandle(content::BlobHandle* handle) const;
+
+ // A reference to the owner of this class.
+ content::RenderProcessHost* render_process_host_;
+
+ BlobHandleMultimap held_blobs_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlobHolder);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_BLOB_HOLDER_H_
« no previous file with comments | « no previous file | extensions/browser/blob_holder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698