| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 ResourceConverter::~ResourceConverter() {} | 197 ResourceConverter::~ResourceConverter() {} |
| 198 | 198 |
| 199 ResourceConverterImpl::ResourceConverterImpl(PP_Instance instance, | 199 ResourceConverterImpl::ResourceConverterImpl(PP_Instance instance, |
| 200 RendererPpapiHost* host) | 200 RendererPpapiHost* host) |
| 201 : instance_(instance), host_(host) {} | 201 : instance_(instance), host_(host) {} |
| 202 | 202 |
| 203 ResourceConverterImpl::~ResourceConverterImpl() { | 203 ResourceConverterImpl::~ResourceConverterImpl() { |
| 204 // Verify Flush() was called. | 204 // Verify Flush() was called. |
| 205 DCHECK(browser_host_create_messages_.empty()); | 205 DCHECK(browser_host_create_messages_.empty()); |
| 206 DCHECK(browser_vars.empty()); | 206 DCHECK(browser_vars_.empty()); |
| 207 } | 207 } |
| 208 | 208 |
| 209 bool ResourceConverterImpl::FromV8Value(v8::Handle<v8::Object> val, | 209 bool ResourceConverterImpl::FromV8Value(v8::Handle<v8::Object> val, |
| 210 v8::Handle<v8::Context> context, | 210 v8::Handle<v8::Context> context, |
| 211 PP_Var* result, | 211 PP_Var* result, |
| 212 bool* was_resource) { | 212 bool* was_resource) { |
| 213 v8::Context::Scope context_scope(context); | 213 v8::Context::Scope context_scope(context); |
| 214 v8::HandleScope handle_scope(context->GetIsolate()); | 214 v8::HandleScope handle_scope(context->GetIsolate()); |
| 215 | 215 |
| 216 *was_resource = false; | 216 *was_resource = false; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // The value was not convertible to a resource. Return true with | 262 // The value was not convertible to a resource. Return true with |
| 263 // |was_resource| set to false. As per the interface of FromV8Value, |result| | 263 // |was_resource| set to false. As per the interface of FromV8Value, |result| |
| 264 // may be left unmodified in this case. | 264 // may be left unmodified in this case. |
| 265 return true; | 265 return true; |
| 266 } | 266 } |
| 267 | 267 |
| 268 void ResourceConverterImpl::Flush(const base::Callback<void(bool)>& callback) { | 268 void ResourceConverterImpl::Flush(const base::Callback<void(bool)>& callback) { |
| 269 host_->CreateBrowserResourceHosts( | 269 host_->CreateBrowserResourceHosts( |
| 270 instance_, | 270 instance_, |
| 271 browser_host_create_messages_, | 271 browser_host_create_messages_, |
| 272 base::Bind(&FlushComplete, callback, browser_vars)); | 272 base::Bind(&FlushComplete, callback, browser_vars_)); |
| 273 browser_host_create_messages_.clear(); | 273 browser_host_create_messages_.clear(); |
| 274 browser_vars.clear(); | 274 browser_vars_.clear(); |
| 275 } | 275 } |
| 276 | 276 |
| 277 bool ResourceConverterImpl::ToV8Value(const PP_Var& var, | 277 bool ResourceConverterImpl::ToV8Value(const PP_Var& var, |
| 278 v8::Handle<v8::Context> context, | 278 v8::Handle<v8::Context> context, |
| 279 v8::Handle<v8::Value>* result) { | 279 v8::Handle<v8::Value>* result) { |
| 280 DCHECK(var.type == PP_VARTYPE_RESOURCE); | 280 DCHECK(var.type == PP_VARTYPE_RESOURCE); |
| 281 | 281 |
| 282 ResourceVar* resource = ResourceVar::FromPPVar(var); | 282 ResourceVar* resource = ResourceVar::FromPPVar(var); |
| 283 if (!resource) { | 283 if (!resource) { |
| 284 NOTREACHED(); | 284 NOTREACHED(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 | 330 |
| 331 scoped_refptr<HostResourceVar> | 331 scoped_refptr<HostResourceVar> |
| 332 ResourceConverterImpl::CreateResourceVarWithBrowserHost( | 332 ResourceConverterImpl::CreateResourceVarWithBrowserHost( |
| 333 int pending_renderer_id, | 333 int pending_renderer_id, |
| 334 const IPC::Message& create_message, | 334 const IPC::Message& create_message, |
| 335 const IPC::Message& browser_host_create_message) { | 335 const IPC::Message& browser_host_create_message) { |
| 336 scoped_refptr<HostResourceVar> result = | 336 scoped_refptr<HostResourceVar> result = |
| 337 CreateResourceVar(pending_renderer_id, create_message); | 337 CreateResourceVar(pending_renderer_id, create_message); |
| 338 browser_host_create_messages_.push_back(browser_host_create_message); | 338 browser_host_create_messages_.push_back(browser_host_create_message); |
| 339 browser_vars.push_back(result); | 339 browser_vars_.push_back(result); |
| 340 return result; | 340 return result; |
| 341 } | 341 } |
| 342 | 342 |
| 343 } // namespace content | 343 } // namespace content |
| OLD | NEW |