OLD | NEW |
---|---|
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 Loading... | |
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 // Flush() or FlushSync must be called before any vars created by the |
raymes
2014/06/10 04:50:47
nit for consistency: FlushSync()
dmichael (off chromium)
2014/06/13 22:01:26
Done. Although I *may* not need it in the short te
| |
38 // are valid. It handles creating any resource hosts that need to be created. | 38 // ResourceConverter are valid. They handle creating any resource hosts that |
39 // need to be created. | |
39 virtual void Flush(const base::Callback<void(bool)>& callback) = 0; | 40 virtual void Flush(const base::Callback<void(bool)>& callback) = 0; |
41 virtual bool FlushSync() = 0; | |
40 | 42 |
41 // Attempts to convert a V8 object to a PP_Var with type PP_VARTYPE_RESOURCE. | 43 // 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 | 44 // 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 | 45 // 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. | 46 // false and returns true. If an error occurs, returns false. |
45 virtual bool FromV8Value(v8::Handle<v8::Object> val, | 47 virtual bool FromV8Value(v8::Handle<v8::Object> val, |
46 v8::Handle<v8::Context> context, | 48 v8::Handle<v8::Context> context, |
47 PP_Var* result, | 49 PP_Var* result, |
48 bool* was_resource) = 0; | 50 bool* was_resource) = 0; |
49 | 51 |
50 // Attempts to convert a PP_Var to a V8 object. |var| must have type | 52 // 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 | 53 // PP_VARTYPE_RESOURCE. On success, writes the resulting value to |result| and |
52 // returns true. If an error occurs, returns false. | 54 // returns true. If an error occurs, returns false. |
53 virtual bool ToV8Value(const PP_Var& var, | 55 virtual bool ToV8Value(const PP_Var& var, |
54 v8::Handle<v8::Context> context, | 56 v8::Handle<v8::Context> context, |
55 v8::Handle<v8::Value>* result) = 0; | 57 v8::Handle<v8::Value>* result) = 0; |
56 }; | 58 }; |
57 | 59 |
58 class ResourceConverterImpl : public ResourceConverter { | 60 class ResourceConverterImpl : public ResourceConverter { |
59 public: | 61 public: |
60 ResourceConverterImpl(PP_Instance instance, RendererPpapiHost* host); | 62 ResourceConverterImpl(PP_Instance instance, RendererPpapiHost* host); |
61 virtual ~ResourceConverterImpl(); | 63 virtual ~ResourceConverterImpl(); |
62 | 64 |
63 // ResourceConverter overrides. | 65 // ResourceConverter overrides. |
64 virtual void Flush(const base::Callback<void(bool)>& callback) OVERRIDE; | 66 virtual void Flush(const base::Callback<void(bool)>& callback) OVERRIDE; |
67 virtual bool FlushSync() OVERRIDE; | |
65 virtual bool FromV8Value(v8::Handle<v8::Object> val, | 68 virtual bool FromV8Value(v8::Handle<v8::Object> val, |
66 v8::Handle<v8::Context> context, | 69 v8::Handle<v8::Context> context, |
67 PP_Var* result, | 70 PP_Var* result, |
68 bool* was_resource) OVERRIDE; | 71 bool* was_resource) OVERRIDE; |
69 virtual bool ToV8Value(const PP_Var& var, | 72 virtual bool ToV8Value(const PP_Var& var, |
70 v8::Handle<v8::Context> context, | 73 v8::Handle<v8::Context> context, |
71 v8::Handle<v8::Value>* result) OVERRIDE; | 74 v8::Handle<v8::Value>* result) OVERRIDE; |
72 | 75 |
73 private: | 76 private: |
74 // Creates a resource var with the given |pending_renderer_id| and | 77 // Creates a resource var with the given |pending_renderer_id| and |
(...skipping 20 matching lines...) Expand all Loading... | |
95 // conveniently passed to |CreateBrowserResourceHosts|. | 98 // conveniently passed to |CreateBrowserResourceHosts|. |
96 std::vector<IPC::Message> browser_host_create_messages_; | 99 std::vector<IPC::Message> browser_host_create_messages_; |
97 // A list of the resource vars associated with browser hosts. | 100 // A list of the resource vars associated with browser hosts. |
98 std::vector<scoped_refptr<HostResourceVar> > browser_vars_; | 101 std::vector<scoped_refptr<HostResourceVar> > browser_vars_; |
99 | 102 |
100 DISALLOW_COPY_AND_ASSIGN(ResourceConverterImpl); | 103 DISALLOW_COPY_AND_ASSIGN(ResourceConverterImpl); |
101 }; | 104 }; |
102 | 105 |
103 } // namespace content | 106 } // namespace content |
104 #endif // CONTENT_RENDERER_PEPPER_RESOURCE_CONVERTER_H | 107 #endif // CONTENT_RENDERER_PEPPER_RESOURCE_CONVERTER_H |
OLD | NEW |