OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/native_client/src/trusted/plugin/plugin.h" | 5 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 wrapper_factory_(NULL), | 268 wrapper_factory_(NULL), |
269 nacl_interface_(NULL), | 269 nacl_interface_(NULL), |
270 uma_interface_(this) { | 270 uma_interface_(this) { |
271 callback_factory_.Initialize(this); | 271 callback_factory_.Initialize(this); |
272 nacl_interface_ = GetNaClInterface(); | 272 nacl_interface_ = GetNaClInterface(); |
273 CHECK(nacl_interface_ != NULL); | 273 CHECK(nacl_interface_ != NULL); |
274 | 274 |
275 // Notify PPB_NaCl_Private that the instance is created before altering any | 275 // Notify PPB_NaCl_Private that the instance is created before altering any |
276 // state that it tracks. | 276 // state that it tracks. |
277 nacl_interface_->InstanceCreated(pp_instance); | 277 nacl_interface_->InstanceCreated(pp_instance); |
278 // We call set_exit_status() here to ensure that the 'exitStatus' property is | |
279 // set. This can only be called when nacl_interface_ is not NULL. | |
280 set_exit_status(-1); | |
281 nexe_file_info_ = kInvalidNaClFileInfo; | 278 nexe_file_info_ = kInvalidNaClFileInfo; |
282 } | 279 } |
283 | 280 |
284 | 281 |
285 Plugin::~Plugin() { | 282 Plugin::~Plugin() { |
286 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); | 283 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); |
287 | 284 |
288 // Destroy the coordinator while the rest of the data is still there | 285 // Destroy the coordinator while the rest of the data is still there |
289 pnacl_coordinator_.reset(NULL); | 286 pnacl_coordinator_.reset(NULL); |
290 | 287 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 error_info.error_code(), | 442 error_info.error_code(), |
446 error_info.message().c_str()); | 443 error_info.message().c_str()); |
447 } | 444 } |
448 | 445 |
449 bool Plugin::DocumentCanRequest(const std::string& url) { | 446 bool Plugin::DocumentCanRequest(const std::string& url) { |
450 CHECK(pp::Module::Get()->core()->IsMainThread()); | 447 CHECK(pp::Module::Get()->core()->IsMainThread()); |
451 CHECK(pp::URLUtil_Dev::Get() != NULL); | 448 CHECK(pp::URLUtil_Dev::Get() != NULL); |
452 return pp::URLUtil_Dev::Get()->DocumentCanRequest(this, pp::Var(url)); | 449 return pp::URLUtil_Dev::Get()->DocumentCanRequest(this, pp::Var(url)); |
453 } | 450 } |
454 | 451 |
455 void Plugin::set_exit_status(int exit_status) { | |
456 pp::Core* core = pp::Module::Get()->core(); | |
457 if (core->IsMainThread()) { | |
458 SetExitStatusOnMainThread(PP_OK, exit_status); | |
459 } else { | |
460 pp::CompletionCallback callback = | |
461 callback_factory_.NewCallback(&Plugin::SetExitStatusOnMainThread, | |
462 exit_status); | |
463 core->CallOnMainThread(0, callback, 0); | |
464 } | |
465 } | |
466 | |
467 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, | |
468 int exit_status) { | |
469 DCHECK(pp::Module::Get()->core()->IsMainThread()); | |
470 DCHECK(nacl_interface_); | |
471 nacl_interface_->SetExitStatus(pp_instance(), exit_status); | |
472 } | |
473 | |
474 | |
475 } // namespace plugin | 452 } // namespace plugin |
OLD | NEW |