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 #ifdef _MSC_VER | 5 #ifdef _MSC_VER |
6 // Do not warn about use of std::copy with raw pointers. | 6 // Do not warn about use of std::copy with raw pointers. |
7 #pragma warning(disable : 4996) | 7 #pragma warning(disable : 4996) |
8 #endif | 8 #endif |
9 | 9 |
10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 | 552 |
553 | 553 |
554 void Plugin::ReportLoadAbort() { | 554 void Plugin::ReportLoadAbort() { |
555 nacl_interface_->ReportLoadAbort(pp_instance()); | 555 nacl_interface_->ReportLoadAbort(pp_instance()); |
556 } | 556 } |
557 | 557 |
558 void Plugin::ReportSelLdrLoadStatus(int status) { | 558 void Plugin::ReportSelLdrLoadStatus(int status) { |
559 HistogramEnumerateSelLdrLoadStatus(static_cast<NaClErrorCode>(status)); | 559 HistogramEnumerateSelLdrLoadStatus(static_cast<NaClErrorCode>(status)); |
560 } | 560 } |
561 | 561 |
562 void Plugin::EnqueueProgressEvent(PP_NaClEventType event_type, | |
563 const nacl::string& url, | |
564 LengthComputable length_computable, | |
565 uint64_t loaded_bytes, | |
566 uint64_t total_bytes) { | |
567 PLUGIN_PRINTF(("Plugin::EnqueueProgressEvent (" | |
568 "event_type='%d', url='%s', length_computable=%d, " | |
569 "loaded=%" NACL_PRIu64 ", total=%" NACL_PRIu64 ")\n", | |
570 static_cast<int>(event_type), | |
571 url.c_str(), | |
572 static_cast<int>(length_computable), | |
573 loaded_bytes, | |
574 total_bytes)); | |
575 | |
576 nacl_interface_->DispatchEvent( | |
577 pp_instance(), | |
578 event_type, | |
579 url.c_str(), | |
580 length_computable == LENGTH_IS_COMPUTABLE ? PP_TRUE : PP_FALSE, | |
581 loaded_bytes, | |
582 total_bytes); | |
583 } | |
584 | |
585 bool Plugin::DocumentCanRequest(const std::string& url) { | 562 bool Plugin::DocumentCanRequest(const std::string& url) { |
586 CHECK(pp::Module::Get()->core()->IsMainThread()); | 563 CHECK(pp::Module::Get()->core()->IsMainThread()); |
587 CHECK(pp::URLUtil_Dev::Get() != NULL); | 564 CHECK(pp::URLUtil_Dev::Get() != NULL); |
588 return pp::URLUtil_Dev::Get()->DocumentCanRequest(this, pp::Var(url)); | 565 return pp::URLUtil_Dev::Get()->DocumentCanRequest(this, pp::Var(url)); |
589 } | 566 } |
590 | 567 |
591 void Plugin::set_exit_status(int exit_status) { | 568 void Plugin::set_exit_status(int exit_status) { |
592 pp::Core* core = pp::Module::Get()->core(); | 569 pp::Core* core = pp::Module::Get()->core(); |
593 if (core->IsMainThread()) { | 570 if (core->IsMainThread()) { |
594 SetExitStatusOnMainThread(PP_OK, exit_status); | 571 SetExitStatusOnMainThread(PP_OK, exit_status); |
595 } else { | 572 } else { |
596 pp::CompletionCallback callback = | 573 pp::CompletionCallback callback = |
597 callback_factory_.NewCallback(&Plugin::SetExitStatusOnMainThread, | 574 callback_factory_.NewCallback(&Plugin::SetExitStatusOnMainThread, |
598 exit_status); | 575 exit_status); |
599 core->CallOnMainThread(0, callback, 0); | 576 core->CallOnMainThread(0, callback, 0); |
600 } | 577 } |
601 } | 578 } |
602 | 579 |
603 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, | 580 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, |
604 int exit_status) { | 581 int exit_status) { |
605 DCHECK(pp::Module::Get()->core()->IsMainThread()); | 582 DCHECK(pp::Module::Get()->core()->IsMainThread()); |
606 DCHECK(nacl_interface_); | 583 DCHECK(nacl_interface_); |
607 nacl_interface_->SetExitStatus(pp_instance(), exit_status); | 584 nacl_interface_->SetExitStatus(pp_instance(), exit_status); |
608 } | 585 } |
609 | 586 |
610 | 587 |
611 } // namespace plugin | 588 } // namespace plugin |
OLD | NEW |