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

Side by Side Diff: content/renderer/pepper/resource_converter.h

Issue 331593002: Change V8VarConverter::FromV8Value to complete synchronously if possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_PEPPER_RESOURCE_CONVERTER_H 5 #ifndef CONTENT_RENDERER_PEPPER_RESOURCE_CONVERTER_H
6 #define CONTENT_RENDERER_PEPPER_RESOURCE_CONVERTER_H 6 #define CONTENT_RENDERER_PEPPER_RESOURCE_CONVERTER_H
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 16 matching lines...) Expand all
27 27
28 namespace content { 28 namespace content {
29 29
30 class RendererPpapiHost; 30 class RendererPpapiHost;
31 31
32 // This class is responsible for converting V8 vars to Pepper resources. 32 // This class is responsible for converting V8 vars to Pepper resources.
33 class CONTENT_EXPORT ResourceConverter { 33 class CONTENT_EXPORT ResourceConverter {
34 public: 34 public:
35 virtual ~ResourceConverter(); 35 virtual ~ResourceConverter();
36 36
37 // Flush() must be called before any vars created by the ResourceConverter 37 // Reset the state of the resource converter.
38 // are valid. It handles creating any resource hosts that need to be created. 38 virtual void Reset() = 0;
39
40 // Returns true if Flush() needs to be called before using any vars created
41 // by the resource converter.
42 virtual bool NeedsFlush() = 0;
43
44 // If NeedsFlush() is true then Flush() must be called before any vars created
45 // by the ResourceConverter are valid. It handles creating any resource hosts
46 // that need to be created. |callback| will always be called asynchronously.
39 virtual void Flush(const base::Callback<void(bool)>& callback) = 0; 47 virtual void Flush(const base::Callback<void(bool)>& callback) = 0;
40 48
41 // Attempts to convert a V8 object to a PP_Var with type PP_VARTYPE_RESOURCE. 49 // Attempts to convert a V8 object to a PP_Var with type PP_VARTYPE_RESOURCE.
42 // On success, writes the resulting var to |result|, sets |was_resource| to 50 // On success, writes the resulting var to |result|, sets |was_resource| to
43 // true and returns true. If |val| is not a resource, sets |was_resource| to 51 // true and returns true. If |val| is not a resource, sets |was_resource| to
44 // false and returns true. If an error occurs, returns false. 52 // false and returns true. If an error occurs, returns false.
45 virtual bool FromV8Value(v8::Handle<v8::Object> val, 53 virtual bool FromV8Value(v8::Handle<v8::Object> val,
46 v8::Handle<v8::Context> context, 54 v8::Handle<v8::Context> context,
47 PP_Var* result, 55 PP_Var* result,
48 bool* was_resource) = 0; 56 bool* was_resource) = 0;
49 57
50 // Attempts to convert a PP_Var to a V8 object. |var| must have type 58 // Attempts to convert a PP_Var to a V8 object. |var| must have type
51 // PP_VARTYPE_RESOURCE. On success, writes the resulting value to |result| and 59 // PP_VARTYPE_RESOURCE. On success, writes the resulting value to |result| and
52 // returns true. If an error occurs, returns false. 60 // returns true. If an error occurs, returns false.
53 virtual bool ToV8Value(const PP_Var& var, 61 virtual bool ToV8Value(const PP_Var& var,
54 v8::Handle<v8::Context> context, 62 v8::Handle<v8::Context> context,
55 v8::Handle<v8::Value>* result) = 0; 63 v8::Handle<v8::Value>* result) = 0;
56 }; 64 };
57 65
58 class ResourceConverterImpl : public ResourceConverter { 66 class ResourceConverterImpl : public ResourceConverter {
59 public: 67 public:
60 ResourceConverterImpl(PP_Instance instance, RendererPpapiHost* host); 68 ResourceConverterImpl(PP_Instance instance, RendererPpapiHost* host);
61 virtual ~ResourceConverterImpl(); 69 virtual ~ResourceConverterImpl();
62 70
63 // ResourceConverter overrides. 71 // ResourceConverter overrides.
72 virtual void Reset() OVERRIDE;
73 virtual bool NeedsFlush() OVERRIDE;
64 virtual void Flush(const base::Callback<void(bool)>& callback) OVERRIDE; 74 virtual void Flush(const base::Callback<void(bool)>& callback) OVERRIDE;
65 virtual bool FromV8Value(v8::Handle<v8::Object> val, 75 virtual bool FromV8Value(v8::Handle<v8::Object> val,
66 v8::Handle<v8::Context> context, 76 v8::Handle<v8::Context> context,
67 PP_Var* result, 77 PP_Var* result,
68 bool* was_resource) OVERRIDE; 78 bool* was_resource) OVERRIDE;
69 virtual bool ToV8Value(const PP_Var& var, 79 virtual bool ToV8Value(const PP_Var& var,
70 v8::Handle<v8::Context> context, 80 v8::Handle<v8::Context> context,
71 v8::Handle<v8::Value>* result) OVERRIDE; 81 v8::Handle<v8::Value>* result) OVERRIDE;
72 82
73 private: 83 private:
(...skipping 21 matching lines...) Expand all
95 // conveniently passed to |CreateBrowserResourceHosts|. 105 // conveniently passed to |CreateBrowserResourceHosts|.
96 std::vector<IPC::Message> browser_host_create_messages_; 106 std::vector<IPC::Message> browser_host_create_messages_;
97 // A list of the resource vars associated with browser hosts. 107 // A list of the resource vars associated with browser hosts.
98 std::vector<scoped_refptr<HostResourceVar> > browser_vars_; 108 std::vector<scoped_refptr<HostResourceVar> > browser_vars_;
99 109
100 DISALLOW_COPY_AND_ASSIGN(ResourceConverterImpl); 110 DISALLOW_COPY_AND_ASSIGN(ResourceConverterImpl);
101 }; 111 };
102 112
103 } // namespace content 113 } // namespace content
104 #endif // CONTENT_RENDERER_PEPPER_RESOURCE_CONVERTER_H 114 #endif // CONTENT_RENDERER_PEPPER_RESOURCE_CONVERTER_H
OLDNEW
« no previous file with comments | « content/renderer/pepper/message_channel.cc ('k') | content/renderer/pepper/resource_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698