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

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

Issue 276423003: Pepper: Nexe downloading out of the trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows fix and stuff for bill Created 6 years, 7 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 | Annotate | Revision Log
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/nexe_load_manager.h" 5 #include "components/nacl/renderer/nexe_load_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_tokenizer.h" 10 #include "base/strings/string_tokenizer.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 NexeLoadManager::~NexeLoadManager() { 102 NexeLoadManager::~NexeLoadManager() {
103 if (!nexe_error_reported_) { 103 if (!nexe_error_reported_) {
104 base::TimeDelta uptime = base::Time::Now() - ready_time_; 104 base::TimeDelta uptime = base::Time::Now() - ready_time_;
105 HistogramTimeLarge("NaCl.ModuleUptime.Normal", uptime.InMilliseconds()); 105 HistogramTimeLarge("NaCl.ModuleUptime.Normal", uptime.InMilliseconds());
106 } 106 }
107 } 107 }
108 108
109 void NexeLoadManager::NexeFileDidOpen(int32_t pp_error, 109 void NexeLoadManager::NexeFileDidOpen(int32_t pp_error,
110 int32_t fd, 110 base::PlatformFile file,
111 int32_t http_status, 111 int32_t http_status,
112 int64_t nexe_bytes_read, 112 int64_t nexe_bytes_read,
113 const std::string& url, 113 const std::string& url,
114 int64_t time_since_open) { 114 base::TimeDelta time_since_open) {
115 // Check that we are on the main renderer thread. 115 // Check that we are on the main renderer thread.
116 DCHECK(content::RenderThread::Get()); 116 DCHECK(content::RenderThread::Get());
117 VLOG(1) << "Plugin::NexeFileDidOpen (pp_error=" << pp_error << ")"; 117 VLOG(1) << "Plugin::NexeFileDidOpen (pp_error=" << pp_error << ")";
118 VLOG(1) << "Plugin::NexeFileDidOpen (file_desc=" << fd << ")";
119 HistogramHTTPStatusCode( 118 HistogramHTTPStatusCode(
120 is_installed_ ? "NaCl.HttpStatusCodeClass.Nexe.InstalledApp" : 119 is_installed_ ? "NaCl.HttpStatusCodeClass.Nexe.InstalledApp" :
121 "NaCl.HttpStatusCodeClass.Nexe.NotInstalledApp", 120 "NaCl.HttpStatusCodeClass.Nexe.NotInstalledApp",
122 http_status); 121 http_status);
123 // TODO(dmichael): fd is only used for error reporting here currently, and 122
124 // the trusted Plugin is responsible for using it and closing it. 123 if (pp_error != PP_OK || file == base::kInvalidPlatformFileValue) {
125 // Note -1 is NACL_NO_FILE_DESC from nacl_macros.h.
126 if (pp_error != PP_OK || fd == -1) {
127 if (pp_error == PP_ERROR_ABORTED) { 124 if (pp_error == PP_ERROR_ABORTED) {
128 ReportLoadAbort(); 125 ReportLoadAbort();
129 } else if (pp_error == PP_ERROR_NOACCESS) { 126 } else if (pp_error == PP_ERROR_NOACCESS) {
130 ReportLoadError(PP_NACL_ERROR_NEXE_NOACCESS_URL, 127 ReportLoadError(PP_NACL_ERROR_NEXE_NOACCESS_URL,
131 "access to nexe url was denied."); 128 "access to nexe url was denied.");
132 } else { 129 } else {
133 ReportLoadError(PP_NACL_ERROR_NEXE_LOAD_URL, 130 ReportLoadError(PP_NACL_ERROR_NEXE_LOAD_URL,
134 "could not load nexe url."); 131 "could not load nexe url.");
135 } 132 }
136 } else if (nexe_bytes_read == -1) { 133 } else if (nexe_bytes_read == -1) {
137 ReportLoadError(PP_NACL_ERROR_NEXE_STAT, "could not stat nexe file."); 134 ReportLoadError(PP_NACL_ERROR_NEXE_STAT, "could not stat nexe file.");
138 } else { 135 } else {
139 // TODO(dmichael): Can we avoid stashing away so much state? 136 // TODO(dmichael): Can we avoid stashing away so much state?
140 nexe_size_ = nexe_bytes_read; 137 nexe_size_ = nexe_bytes_read;
141 HistogramSizeKB("NaCl.Perf.Size.Nexe", 138 HistogramSizeKB("NaCl.Perf.Size.Nexe",
142 static_cast<int32_t>(nexe_size_ / 1024)); 139 static_cast<int32_t>(nexe_size_ / 1024));
143 HistogramStartupTimeMedium( 140 HistogramStartupTimeMedium(
144 "NaCl.Perf.StartupTime.NexeDownload", 141 "NaCl.Perf.StartupTime.NexeDownload", time_since_open, nexe_size_);
145 base::TimeDelta::FromMilliseconds(time_since_open),
146 nexe_size_);
147 142
148 // Inform JavaScript that we successfully downloaded the nacl module. 143 // Inform JavaScript that we successfully downloaded the nacl module.
149 ProgressEvent progress_event(PP_NACL_EVENT_PROGRESS, url, true, nexe_size_, 144 ProgressEvent progress_event(PP_NACL_EVENT_PROGRESS, url, true, nexe_size_,
150 nexe_size_); 145 nexe_size_);
151 DispatchProgressEvent(pp_instance_, progress_event); 146 DispatchProgressEvent(pp_instance_, progress_event);
152 load_start_ = base::Time::Now(); 147 load_start_ = base::Time::Now();
153 } 148 }
154 } 149 }
155 150
156 void NexeLoadManager::ReportLoadSuccess(const std::string& url, 151 void NexeLoadManager::ReportLoadSuccess(const std::string& url,
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 // to provide error handling. 419 // to provide error handling.
425 } 420 }
426 421
427 void NexeLoadManager::CopyCrashLogToJsConsole(const std::string& crash_log) { 422 void NexeLoadManager::CopyCrashLogToJsConsole(const std::string& crash_log) {
428 base::StringTokenizer t(crash_log, "\n"); 423 base::StringTokenizer t(crash_log, "\n");
429 while (t.GetNext()) 424 while (t.GetNext())
430 LogToConsole(t.token()); 425 LogToConsole(t.token());
431 } 426 }
432 427
433 } // namespace nacl 428 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698