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 #include "content/renderer/pepper/resource_converter.h" | 5 #include "content/renderer/pepper/resource_converter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
10 #include "content/renderer/pepper/pepper_file_system_host.h" | 10 #include "content/renderer/pepper/pepper_file_system_host.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 const base::Callback<void(bool)>& callback, | 23 const base::Callback<void(bool)>& callback, |
24 const std::vector<scoped_refptr<content::HostResourceVar> >& browser_vars, | 24 const std::vector<scoped_refptr<content::HostResourceVar> >& browser_vars, |
25 const std::vector<int>& pending_host_ids) { | 25 const std::vector<int>& pending_host_ids) { |
26 CHECK(browser_vars.size() == pending_host_ids.size()); | 26 CHECK(browser_vars.size() == pending_host_ids.size()); |
27 for (size_t i = 0; i < browser_vars.size(); ++i) { | 27 for (size_t i = 0; i < browser_vars.size(); ++i) { |
28 browser_vars[i]->set_pending_browser_host_id(pending_host_ids[i]); | 28 browser_vars[i]->set_pending_browser_host_id(pending_host_ids[i]); |
29 } | 29 } |
30 callback.Run(true); | 30 callback.Run(true); |
31 } | 31 } |
32 | 32 |
33 // Converts a WebKit::WebFileSystem::Type to a PP_FileSystemType. | 33 // Converts a blink::WebFileSystem::Type to a PP_FileSystemType. |
34 PP_FileSystemType WebFileSystemTypeToPPAPI(WebKit::WebFileSystem::Type type) { | 34 PP_FileSystemType WebFileSystemTypeToPPAPI(blink::WebFileSystem::Type type) { |
35 switch (type) { | 35 switch (type) { |
36 case WebKit::WebFileSystem::TypeTemporary: | 36 case blink::WebFileSystem::TypeTemporary: |
37 return PP_FILESYSTEMTYPE_LOCALTEMPORARY; | 37 return PP_FILESYSTEMTYPE_LOCALTEMPORARY; |
38 case WebKit::WebFileSystem::TypePersistent: | 38 case blink::WebFileSystem::TypePersistent: |
39 return PP_FILESYSTEMTYPE_LOCALPERSISTENT; | 39 return PP_FILESYSTEMTYPE_LOCALPERSISTENT; |
40 case WebKit::WebFileSystem::TypeIsolated: | 40 case blink::WebFileSystem::TypeIsolated: |
41 return PP_FILESYSTEMTYPE_ISOLATED; | 41 return PP_FILESYSTEMTYPE_ISOLATED; |
42 case WebKit::WebFileSystem::TypeExternal: | 42 case blink::WebFileSystem::TypeExternal: |
43 return PP_FILESYSTEMTYPE_EXTERNAL; | 43 return PP_FILESYSTEMTYPE_EXTERNAL; |
44 default: | 44 default: |
45 NOTREACHED(); | 45 NOTREACHED(); |
46 return PP_FILESYSTEMTYPE_LOCALTEMPORARY; | 46 return PP_FILESYSTEMTYPE_LOCALTEMPORARY; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 // Given a V8 value containing a DOMFileSystem, creates a resource host and | 50 // Given a V8 value containing a DOMFileSystem, creates a resource host and |
51 // returns the resource information for serialization. | 51 // returns the resource information for serialization. |
52 // On error, false. | 52 // On error, false. |
53 bool DOMFileSystemToResource( | 53 bool DOMFileSystemToResource( |
54 PP_Instance instance, | 54 PP_Instance instance, |
55 content::RendererPpapiHost* host, | 55 content::RendererPpapiHost* host, |
56 const WebKit::WebDOMFileSystem& dom_file_system, | 56 const blink::WebDOMFileSystem& dom_file_system, |
57 int* pending_renderer_id, | 57 int* pending_renderer_id, |
58 scoped_ptr<IPC::Message>* create_message, | 58 scoped_ptr<IPC::Message>* create_message, |
59 scoped_ptr<IPC::Message>* browser_host_create_message) { | 59 scoped_ptr<IPC::Message>* browser_host_create_message) { |
60 DCHECK(!dom_file_system.isNull()); | 60 DCHECK(!dom_file_system.isNull()); |
61 | 61 |
62 PP_FileSystemType file_system_type = | 62 PP_FileSystemType file_system_type = |
63 WebFileSystemTypeToPPAPI(dom_file_system.type()); | 63 WebFileSystemTypeToPPAPI(dom_file_system.type()); |
64 GURL root_url = dom_file_system.rootURL(); | 64 GURL root_url = dom_file_system.rootURL(); |
65 | 65 |
66 // External file systems are not currently supported. (Without this check, | 66 // External file systems are not currently supported. (Without this check, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 bool ResourceConverterImpl::FromV8Value(v8::Handle<v8::Object> val, | 106 bool ResourceConverterImpl::FromV8Value(v8::Handle<v8::Object> val, |
107 v8::Handle<v8::Context> context, | 107 v8::Handle<v8::Context> context, |
108 PP_Var* result, | 108 PP_Var* result, |
109 bool* was_resource) { | 109 bool* was_resource) { |
110 v8::Context::Scope context_scope(context); | 110 v8::Context::Scope context_scope(context); |
111 v8::HandleScope handle_scope(context->GetIsolate()); | 111 v8::HandleScope handle_scope(context->GetIsolate()); |
112 | 112 |
113 *was_resource = false; | 113 *was_resource = false; |
114 | 114 |
115 WebKit::WebDOMFileSystem dom_file_system = | 115 blink::WebDOMFileSystem dom_file_system = |
116 WebKit::WebDOMFileSystem::fromV8Value(val); | 116 blink::WebDOMFileSystem::fromV8Value(val); |
117 if (!dom_file_system.isNull()) { | 117 if (!dom_file_system.isNull()) { |
118 int pending_renderer_id; | 118 int pending_renderer_id; |
119 scoped_ptr<IPC::Message> create_message; | 119 scoped_ptr<IPC::Message> create_message; |
120 scoped_ptr<IPC::Message> browser_host_create_message; | 120 scoped_ptr<IPC::Message> browser_host_create_message; |
121 if (!DOMFileSystemToResource(instance_, host_, dom_file_system, | 121 if (!DOMFileSystemToResource(instance_, host_, dom_file_system, |
122 &pending_renderer_id, &create_message, | 122 &pending_renderer_id, &create_message, |
123 &browser_host_create_message)) { | 123 &browser_host_create_message)) { |
124 return false; | 124 return false; |
125 } | 125 } |
126 DCHECK(create_message); | 126 DCHECK(create_message); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 const IPC::Message& create_message, | 160 const IPC::Message& create_message, |
161 const IPC::Message& browser_host_create_message) { | 161 const IPC::Message& browser_host_create_message) { |
162 scoped_refptr<HostResourceVar> result = | 162 scoped_refptr<HostResourceVar> result = |
163 CreateResourceVar(pending_renderer_id, create_message); | 163 CreateResourceVar(pending_renderer_id, create_message); |
164 browser_host_create_messages_.push_back(browser_host_create_message); | 164 browser_host_create_messages_.push_back(browser_host_create_message); |
165 browser_vars.push_back(result); | 165 browser_vars.push_back(result); |
166 return result; | 166 return result; |
167 } | 167 } |
168 | 168 |
169 } // namespace content | 169 } // namespace content |
OLD | NEW |