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

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

Issue 1090233003: Set up a NaCl load status callback to start replacing "start_module". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use the enum instead of int Created 5 years, 8 months 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
« no previous file with comments | « components/nacl/renderer/trusted_plugin_channel.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" 8 #include "components/nacl/common/nacl_renderer_messages.h"
9 #include "components/nacl/renderer/histogram.h"
9 #include "components/nacl/renderer/nexe_load_manager.h" 10 #include "components/nacl/renderer/nexe_load_manager.h"
10 #include "content/public/renderer/render_thread.h" 11 #include "content/public/renderer/render_thread.h"
11 #include "ipc/ipc_sync_channel.h" 12 #include "ipc/ipc_sync_channel.h"
12 #include "ipc/ipc_message_macros.h" 13 #include "ipc/ipc_message_macros.h"
13 #include "ppapi/c/pp_errors.h" 14 #include "ppapi/c/pp_errors.h"
14 15
15 namespace nacl { 16 namespace nacl {
16 17
17 TrustedPluginChannel::TrustedPluginChannel( 18 TrustedPluginChannel::TrustedPluginChannel(
18 NexeLoadManager* nexe_load_manager, 19 NexeLoadManager* nexe_load_manager,
19 const IPC::ChannelHandle& handle, 20 const IPC::ChannelHandle& handle,
20 base::WaitableEvent* shutdown_event, 21 base::WaitableEvent* shutdown_event,
21 bool report_exit_status) 22 bool is_helper_nexe)
22 : nexe_load_manager_(nexe_load_manager), 23 : nexe_load_manager_(nexe_load_manager),
23 report_exit_status_(report_exit_status) { 24 is_helper_nexe_(is_helper_nexe) {
24 channel_ = IPC::SyncChannel::Create( 25 channel_ = IPC::SyncChannel::Create(
25 handle, 26 handle,
26 IPC::Channel::MODE_CLIENT, 27 IPC::Channel::MODE_CLIENT,
27 this, 28 this,
28 content::RenderThread::Get()->GetIOMessageLoopProxy(), 29 content::RenderThread::Get()->GetIOMessageLoopProxy(),
29 true, 30 true,
30 shutdown_event).Pass(); 31 shutdown_event).Pass();
31 } 32 }
32 33
33 TrustedPluginChannel::~TrustedPluginChannel() { 34 TrustedPluginChannel::~TrustedPluginChannel() {
34 } 35 }
35 36
36 bool TrustedPluginChannel::Send(IPC::Message* message) { 37 bool TrustedPluginChannel::Send(IPC::Message* message) {
37 return channel_->Send(message); 38 return channel_->Send(message);
38 } 39 }
39 40
40 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& msg) { 41 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& msg) {
41 bool handled = true; 42 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(TrustedPluginChannel, msg) 43 IPC_BEGIN_MESSAGE_MAP(TrustedPluginChannel, msg)
43 IPC_MESSAGE_HANDLER(NaClRendererMsg_ReportExitStatus, OnReportExitStatus); 44 IPC_MESSAGE_HANDLER(NaClRendererMsg_ReportExitStatus, OnReportExitStatus);
45 IPC_MESSAGE_HANDLER(NaClRendererMsg_ReportLoadStatus, OnReportLoadStatus);
44 IPC_MESSAGE_UNHANDLED(handled = false); 46 IPC_MESSAGE_UNHANDLED(handled = false);
45 IPC_END_MESSAGE_MAP() 47 IPC_END_MESSAGE_MAP()
46 return handled; 48 return handled;
47 } 49 }
48 50
49 void TrustedPluginChannel::OnChannelError() { 51 void TrustedPluginChannel::OnChannelError() {
50 if (report_exit_status_) 52 if (!is_helper_nexe_)
51 nexe_load_manager_->NexeDidCrash(); 53 nexe_load_manager_->NexeDidCrash();
52 } 54 }
53 55
54 void TrustedPluginChannel::OnReportExitStatus(int exit_status) { 56 void TrustedPluginChannel::OnReportExitStatus(int exit_status) {
55 if (report_exit_status_) 57 if (!is_helper_nexe_)
56 nexe_load_manager_->set_exit_status(exit_status); 58 nexe_load_manager_->set_exit_status(exit_status);
57 } 59 }
58 60
61 void TrustedPluginChannel::OnReportLoadStatus(NaClErrorCode load_status) {
62 if (load_status < 0 || load_status > NACL_ERROR_CODE_MAX) {
63 load_status = LOAD_STATUS_UNKNOWN;
64 }
65 // For now, we only report UMA for non-helper nexes
66 // (don't report for the PNaCl translators nexes).
67 if (!is_helper_nexe_) {
68 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status,
69 NACL_ERROR_CODE_MAX);
70 // Gather data to see if being installed changes load outcomes.
71 const char* name = nexe_load_manager_->is_installed()
72 ? "NaCl.LoadStatus.SelLdr.InstalledApp"
73 : "NaCl.LoadStatus.SelLdr.NotInstalledApp";
74 HistogramEnumerate(name, load_status, NACL_ERROR_CODE_MAX);
75 }
76 if (load_status != LOAD_OK) {
77 nexe_load_manager_->ReportLoadError(PP_NACL_ERROR_SEL_LDR_START_STATUS,
78 NaClErrorString(load_status));
79 }
80 }
81
59 } // namespace nacl 82 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/renderer/trusted_plugin_channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698