Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: components/nacl/renderer/trusted_plugin_channel.cc

Issue 2525483002: Convert NaCl renderer-loader messages to mojo. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/trusted_plugin_channel.h" 5 #include "components/nacl/renderer/trusted_plugin_channel.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "components/nacl/common/nacl_renderer_messages.h"
9 #include "components/nacl/renderer/histogram.h" 8 #include "components/nacl/renderer/histogram.h"
10 #include "components/nacl/renderer/nexe_load_manager.h" 9 #include "components/nacl/renderer/nexe_load_manager.h"
11 #include "content/public/renderer/render_thread.h"
12 #include "ipc/ipc_sync_channel.h"
13 #include "ipc/ipc_message_macros.h"
14 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
15 11
16 namespace nacl { 12 namespace nacl {
17 13
18 TrustedPluginChannel::TrustedPluginChannel( 14 TrustedPluginChannel::TrustedPluginChannel(
19 NexeLoadManager* nexe_load_manager, 15 NexeLoadManager* nexe_load_manager,
20 const IPC::ChannelHandle& handle, 16 mojom::NaClRendererHostRequest request,
21 base::WaitableEvent* shutdown_event,
22 bool is_helper_nexe) 17 bool is_helper_nexe)
23 : nexe_load_manager_(nexe_load_manager), 18 : nexe_load_manager_(nexe_load_manager),
19 binding_(this, std::move(request)),
24 is_helper_nexe_(is_helper_nexe) { 20 is_helper_nexe_(is_helper_nexe) {
25 channel_ = IPC::SyncChannel::Create( 21 binding_.set_connection_error_handler(base::Bind(
26 handle, IPC::Channel::MODE_CLIENT, this, 22 &TrustedPluginChannel::OnChannelError, base::Unretained(this)));
27 content::RenderThread::Get()->GetIOTaskRunner(), true, shutdown_event);
28 } 23 }
29 24
30 TrustedPluginChannel::~TrustedPluginChannel() { 25 TrustedPluginChannel::~TrustedPluginChannel() {
31 } 26 }
32 27
33 bool TrustedPluginChannel::Send(IPC::Message* message) {
34 return channel_->Send(message);
35 }
36
37 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& msg) {
38 bool handled = true;
39 IPC_BEGIN_MESSAGE_MAP(TrustedPluginChannel, msg)
40 IPC_MESSAGE_HANDLER(NaClRendererMsg_ReportExitStatus, OnReportExitStatus);
41 IPC_MESSAGE_HANDLER(NaClRendererMsg_ReportLoadStatus, OnReportLoadStatus);
42 IPC_MESSAGE_UNHANDLED(handled = false)
43 IPC_END_MESSAGE_MAP()
44 return handled;
45 }
46
47 void TrustedPluginChannel::OnChannelError() { 28 void TrustedPluginChannel::OnChannelError() {
48 if (!is_helper_nexe_) 29 if (!is_helper_nexe_)
49 nexe_load_manager_->NexeDidCrash(); 30 nexe_load_manager_->NexeDidCrash();
50 } 31 }
51 32
52 void TrustedPluginChannel::OnReportExitStatus(int exit_status) { 33 void TrustedPluginChannel::ReportExitStatus(
34 int exit_status,
35 const ReportExitStatusCallback& callback) {
36 callback.Run();
53 if (!is_helper_nexe_) 37 if (!is_helper_nexe_)
54 nexe_load_manager_->set_exit_status(exit_status); 38 nexe_load_manager_->set_exit_status(exit_status);
55 } 39 }
56 40
57 void TrustedPluginChannel::OnReportLoadStatus(NaClErrorCode load_status) { 41 void TrustedPluginChannel::ReportLoadStatus(
42 NaClErrorCode load_status,
43 const ReportLoadStatusCallback& callback) {
44 callback.Run();
58 if (load_status < 0 || load_status > NACL_ERROR_CODE_MAX) { 45 if (load_status < 0 || load_status > NACL_ERROR_CODE_MAX) {
59 load_status = LOAD_STATUS_UNKNOWN; 46 load_status = LOAD_STATUS_UNKNOWN;
60 } 47 }
61 // For now, we only report UMA for non-helper nexes 48 // For now, we only report UMA for non-helper nexes
62 // (don't report for the PNaCl translators nexes). 49 // (don't report for the PNaCl translators nexes).
63 if (!is_helper_nexe_) { 50 if (!is_helper_nexe_) {
64 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status, 51 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status,
65 NACL_ERROR_CODE_MAX); 52 NACL_ERROR_CODE_MAX);
66 // Gather data to see if being installed changes load outcomes. 53 // Gather data to see if being installed changes load outcomes.
67 const char* name = nexe_load_manager_->is_installed() 54 const char* name = nexe_load_manager_->is_installed()
68 ? "NaCl.LoadStatus.SelLdr.InstalledApp" 55 ? "NaCl.LoadStatus.SelLdr.InstalledApp"
69 : "NaCl.LoadStatus.SelLdr.NotInstalledApp"; 56 : "NaCl.LoadStatus.SelLdr.NotInstalledApp";
70 HistogramEnumerate(name, load_status, NACL_ERROR_CODE_MAX); 57 HistogramEnumerate(name, load_status, NACL_ERROR_CODE_MAX);
71 } 58 }
72 if (load_status != LOAD_OK) { 59 if (load_status != LOAD_OK) {
73 nexe_load_manager_->ReportLoadError(PP_NACL_ERROR_SEL_LDR_START_STATUS, 60 nexe_load_manager_->ReportLoadError(PP_NACL_ERROR_SEL_LDR_START_STATUS,
74 NaClErrorString(load_status)); 61 NaClErrorString(load_status));
75 } 62 }
76 } 63 }
77 64
65 void TrustedPluginChannel::ProvideExitControl(
66 mojom::NaClExitControlPtr exit_control) {
67 exit_control_ = std::move(exit_control);
68 }
69
78 } // namespace nacl 70 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698