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 "components/nacl/renderer/ppb_nacl_private_impl.h" | 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
14 #include "components/nacl/common/nacl_host_messages.h" | 14 #include "components/nacl/common/nacl_host_messages.h" |
15 #include "components/nacl/common/nacl_messages.h" | 15 #include "components/nacl/common/nacl_messages.h" |
16 #include "components/nacl/common/nacl_switches.h" | 16 #include "components/nacl/common/nacl_switches.h" |
17 #include "components/nacl/common/nacl_types.h" | 17 #include "components/nacl/common/nacl_types.h" |
18 #include "components/nacl/renderer/histogram.h" | 18 #include "components/nacl/renderer/histogram.h" |
19 #include "components/nacl/renderer/json_manifest.h" | 19 #include "components/nacl/renderer/json_manifest.h" |
20 #include "components/nacl/renderer/manifest_downloader.h" | 20 #include "components/nacl/renderer/manifest_downloader.h" |
21 #include "components/nacl/renderer/manifest_service_channel.h" | 21 #include "components/nacl/renderer/manifest_service_channel.h" |
22 #include "components/nacl/renderer/nexe_load_manager.h" | 22 #include "components/nacl/renderer/nexe_load_manager.h" |
23 #include "components/nacl/renderer/pnacl_translation_resource_host.h" | 23 #include "components/nacl/renderer/pnacl_translation_resource_host.h" |
24 #include "components/nacl/renderer/progress_event.h" | |
24 #include "components/nacl/renderer/sandbox_arch.h" | 25 #include "components/nacl/renderer/sandbox_arch.h" |
25 #include "components/nacl/renderer/trusted_plugin_channel.h" | 26 #include "components/nacl/renderer/trusted_plugin_channel.h" |
26 #include "content/public/common/content_client.h" | 27 #include "content/public/common/content_client.h" |
27 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
28 #include "content/public/common/sandbox_init.h" | 29 #include "content/public/common/sandbox_init.h" |
29 #include "content/public/renderer/pepper_plugin_instance.h" | 30 #include "content/public/renderer/pepper_plugin_instance.h" |
30 #include "content/public/renderer/render_thread.h" | 31 #include "content/public/renderer/render_thread.h" |
31 #include "content/public/renderer/render_view.h" | 32 #include "content/public/renderer/render_view.h" |
32 #include "content/public/renderer/renderer_ppapi_host.h" | 33 #include "content/public/renderer/renderer_ppapi_host.h" |
33 #include "net/base/data_url.h" | 34 #include "net/base/data_url.h" |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 | 636 |
636 if (out_fd == IPC::InvalidPlatformFileForTransit()) { | 637 if (out_fd == IPC::InvalidPlatformFileForTransit()) { |
637 return base::kInvalidPlatformFileValue; | 638 return base::kInvalidPlatformFileValue; |
638 } | 639 } |
639 | 640 |
640 base::PlatformFile handle = | 641 base::PlatformFile handle = |
641 IPC::PlatformFileForTransitToPlatformFile(out_fd); | 642 IPC::PlatformFileForTransitToPlatformFile(out_fd); |
642 return handle; | 643 return handle; |
643 } | 644 } |
644 | 645 |
645 void DispatchEventOnMainThread(PP_Instance instance, | |
646 PP_NaClEventType event_type, | |
647 const std::string& resource_url, | |
648 PP_Bool length_is_computable, | |
649 uint64_t loaded_bytes, | |
650 uint64_t total_bytes); | |
651 | |
652 void DispatchEvent(PP_Instance instance, | 646 void DispatchEvent(PP_Instance instance, |
653 PP_NaClEventType event_type, | 647 PP_NaClEventType event_type, |
654 const char *resource_url, | 648 const char *resource_url, |
655 PP_Bool length_is_computable, | 649 PP_Bool length_is_computable, |
656 uint64_t loaded_bytes, | 650 uint64_t loaded_bytes, |
657 uint64_t total_bytes) { | 651 uint64_t total_bytes) { |
658 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 652 ProgressEvent event(event_type); |
659 FROM_HERE, | 653 event.resource_url = resource_url; |
660 base::Bind(&DispatchEventOnMainThread, | 654 event.length_is_computable = PP_ToBool(length_is_computable); |
661 instance, | 655 event.loaded_bytes = loaded_bytes; |
662 event_type, | 656 event.total_bytes = total_bytes; |
dmichael (off chromium)
2014/05/08 16:19:02
I don't particularly care, but this looks like it
teravest
2014/05/08 16:42:03
Done.
| |
663 std::string(resource_url), | 657 PostDispatchProgressEvent(instance, event); |
664 length_is_computable, | |
665 loaded_bytes, | |
666 total_bytes)); | |
667 } | |
668 | |
669 void DispatchEventOnMainThread(PP_Instance instance, | |
670 PP_NaClEventType event_type, | |
671 const std::string& resource_url, | |
672 PP_Bool length_is_computable, | |
673 uint64_t loaded_bytes, | |
674 uint64_t total_bytes) { | |
675 NexeLoadManager* load_manager = | |
676 GetNexeLoadManager(instance); | |
677 // The instance may have been destroyed after we were scheduled, so do | |
678 // nothing if it's gone. | |
679 if (load_manager) { | |
680 NexeLoadManager::ProgressEvent event(event_type); | |
681 event.resource_url = resource_url; | |
682 event.length_is_computable = PP_ToBool(length_is_computable); | |
683 event.loaded_bytes = loaded_bytes; | |
684 event.total_bytes = total_bytes; | |
685 load_manager->DispatchEvent(event); | |
686 } | |
687 } | 658 } |
688 | 659 |
689 void NexeFileDidOpen(PP_Instance instance, | 660 void NexeFileDidOpen(PP_Instance instance, |
690 int32_t pp_error, | 661 int32_t pp_error, |
691 int32_t fd, | 662 int32_t fd, |
692 int32_t http_status, | 663 int32_t http_status, |
693 int64_t nexe_bytes_read, | 664 int64_t nexe_bytes_read, |
694 const char* url, | 665 const char* url, |
695 int64_t time_since_open) { | 666 int64_t time_since_open) { |
696 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 667 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1225 &GetPNaClResourceInfo | 1196 &GetPNaClResourceInfo |
1226 }; | 1197 }; |
1227 | 1198 |
1228 } // namespace | 1199 } // namespace |
1229 | 1200 |
1230 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1201 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1231 return &nacl_interface; | 1202 return &nacl_interface; |
1232 } | 1203 } |
1233 | 1204 |
1234 } // namespace nacl | 1205 } // namespace nacl |
OLD | NEW |