Index: chrome/browser/extensions/blob_holder.h |
diff --git a/chrome/browser/extensions/blob_holder.h b/chrome/browser/extensions/blob_holder.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f7114131a938e52dd8dd67fa4972a7d04d44695c |
--- /dev/null |
+++ b/chrome/browser/extensions/blob_holder.h |
@@ -0,0 +1,57 @@ |
+// 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 CHROME_BROWSER_EXTENSIONS_BLOB_HOLDER_H_ |
+#define CHROME_BROWSER_EXTENSIONS_BLOB_HOLDER_H_ |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "base/memory/scoped_vector.h" |
+#include "content/public/browser/web_contents_observer.h" |
+#include "content/public/browser/web_contents_user_data.h" |
+ |
+namespace content { |
+class BlobHandle; |
+class RenderViewHost; |
+} |
+ |
+namespace extensions { |
+ |
+// Used for holding onto Blobs created into the browser process until a |
+// renderer takes over ownership. Each Blob is associated with a specific |
+// RenderViewHost. If the RenderViewHost is deleted before it can take ownership |
+// of the Blob, the Blob reference is released. |
+class BlobHolder : public content::WebContentsObserver, |
+ public content::WebContentsUserData<BlobHolder> { |
+ public: |
+ virtual ~BlobHolder(); |
+ |
+ void HoldBlobReference(content::RenderViewHost* render_view_host, |
+ scoped_ptr<content::BlobHandle> blob); |
+ |
+ private: |
+ struct BlobHolderData; |
+ |
+ explicit BlobHolder(content::WebContents* web_contents); |
+ friend class content::WebContentsUserData<BlobHolder>; |
+ |
+ bool ContainsUUID(const std::string& uuid) const; |
+ |
+ // content::WebContentsObserver overrides. |
+ // Releases all the Blob references associated with this render_view_host. |
+ virtual void RenderViewDeleted( |
+ content::RenderViewHost* render_view_host) OVERRIDE; |
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
+ |
+ // Message handlers. |
+ void OnBlobOwnershipTaken(const std::string& uuid); |
+ |
+ // The BlobHandles associated with each RenderViewHost. |
+ ScopedVector<BlobHolderData> held_blobs_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BlobHolder); |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_BLOB_HOLDER_H_ |