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

Unified Diff: content/renderer/pepper/resource_converter.h

Issue 605593002: PPAPI: Support sending browser-hosted resources synchronously Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix content_browsertests Created 6 years, 1 month 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 | « content/renderer/pepper/renderer_ppapi_host_impl.cc ('k') | content/renderer/pepper/resource_converter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/resource_converter.h
diff --git a/content/renderer/pepper/resource_converter.h b/content/renderer/pepper/resource_converter.h
index d669e7464b4ad094dc4fb0eb3eea10bc0e92c990..70b92535ded0aa1716b29b2e5980577505e3d0f0 100644
--- a/content/renderer/pepper/resource_converter.h
+++ b/content/renderer/pepper/resource_converter.h
@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "content/renderer/pepper/host_resource_var.h"
#include "ppapi/c/pp_instance.h"
@@ -22,9 +23,15 @@ class Message;
}
namespace ppapi {
+
class ScopedPPVar;
+
+namespace proxy {
+struct CompletedBrowserResourceHosts;
}
+} // namespace ppapi
+
namespace content {
// This class is responsible for converting V8 vars to Pepper resources.
@@ -43,6 +50,9 @@ class CONTENT_EXPORT ResourceConverter {
// by the ResourceConverter are valid. It handles creating any resource hosts
// that need to be created. |callback| will always be called asynchronously.
virtual void Flush(const base::Callback<void(bool)>& callback) = 0;
+ // Flush, but don't return until the resource hosts are all created, including
+ // in the browser side.
+ virtual void FlushSync() = 0;
// Attempts to convert a V8 object to a PP_Var with type PP_VARTYPE_RESOURCE.
// On success, writes the resulting var to |result|, sets |was_resource| to
@@ -70,6 +80,7 @@ class ResourceConverterImpl : public ResourceConverter {
void Reset() override;
bool NeedsFlush() override;
void Flush(const base::Callback<void(bool)>& callback) override;
+ void FlushSync() override;
bool FromV8Value(v8::Handle<v8::Object> val,
v8::Handle<v8::Context> context,
PP_Var* result,
@@ -79,6 +90,17 @@ class ResourceConverterImpl : public ResourceConverter {
v8::Handle<v8::Value>* result) override;
private:
+ // A list of the resource vars associated with browser hosts.
+ typedef std::vector<scoped_refptr<HostResourceVar>> VarVector;
+
+ struct PendingConversion {
+ PendingConversion();
+ ~PendingConversion();
+ int sequence_num;
+ base::Callback<void(bool)> callback;
+ VarVector browser_vars;
+ };
+
// Creates a resource var with the given |pending_renderer_id| and
// |create_message| to be sent to the plugin.
scoped_refptr<HostResourceVar> CreateResourceVar(
@@ -93,6 +115,8 @@ class ResourceConverterImpl : public ResourceConverter {
const IPC::Message& create_message,
const IPC::Message& browser_host_create_message);
+ void FlushComplete(const ppapi::proxy::CompletedBrowserResourceHosts& hosts);
+
// The instance this ResourceConverter is associated with.
PP_Instance instance_;
@@ -100,8 +124,11 @@ class ResourceConverterImpl : public ResourceConverter {
// array to |browser_vars|. It is kept as a parallel array so that it can be
// conveniently passed to |CreateBrowserResourceHosts|.
std::vector<IPC::Message> browser_host_create_messages_;
- // A list of the resource vars associated with browser hosts.
- std::vector<scoped_refptr<HostResourceVar> > browser_vars_;
+ VarVector browser_vars_;
+
+ std::queue<PendingConversion> pending_conversions_;
+
+ base::WeakPtrFactory<ResourceConverterImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ResourceConverterImpl);
};
« no previous file with comments | « content/renderer/pepper/renderer_ppapi_host_impl.cc ('k') | content/renderer/pepper/resource_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698