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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/plugin.cc

Issue 181933005: Pepper: Simplify FileDownloader::url(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 (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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 742
743 nexe_size_ = nexe_bytes_read; 743 nexe_size_ = nexe_bytes_read;
744 HistogramSizeKB("NaCl.Perf.Size.Nexe", 744 HistogramSizeKB("NaCl.Perf.Size.Nexe",
745 static_cast<int32_t>(nexe_size_ / 1024)); 745 static_cast<int32_t>(nexe_size_ / 1024));
746 HistogramStartupTimeMedium( 746 HistogramStartupTimeMedium(
747 "NaCl.Perf.StartupTime.NexeDownload", 747 "NaCl.Perf.StartupTime.NexeDownload",
748 static_cast<float>(nexe_downloader_.TimeSinceOpenMilliseconds())); 748 static_cast<float>(nexe_downloader_.TimeSinceOpenMilliseconds()));
749 749
750 // Inform JavaScript that we successfully downloaded the nacl module. 750 // Inform JavaScript that we successfully downloaded the nacl module.
751 EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS, 751 EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS,
752 nexe_downloader_.url_to_open(), 752 nexe_downloader_.url(),
753 LENGTH_IS_COMPUTABLE, 753 LENGTH_IS_COMPUTABLE,
754 nexe_bytes_read, 754 nexe_bytes_read,
755 nexe_bytes_read); 755 nexe_bytes_read);
756 756
757 load_start_ = NaClGetTimeOfDayMicroseconds(); 757 load_start_ = NaClGetTimeOfDayMicroseconds();
758 nacl::scoped_ptr<nacl::DescWrapper> 758 nacl::scoped_ptr<nacl::DescWrapper>
759 wrapper(wrapper_factory()->MakeFileDesc(file_desc_ok_to_close, O_RDONLY)); 759 wrapper(wrapper_factory()->MakeFileDesc(file_desc_ok_to_close, O_RDONLY));
760 NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n"); 760 NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n");
761 LoadNaClModule( 761 LoadNaClModule(
762 wrapper.release(), 762 wrapper.release(),
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 url_downloaders_.erase(url_downloader); 1157 url_downloaders_.erase(url_downloader);
1158 nacl::scoped_ptr<FileDownloader> scoped_url_downloader(url_downloader); 1158 nacl::scoped_ptr<FileDownloader> scoped_url_downloader(url_downloader);
1159 NaClFileInfo tmp_info(scoped_url_downloader->GetFileInfo()); 1159 NaClFileInfo tmp_info(scoped_url_downloader->GetFileInfo());
1160 NaClFileInfoAutoCloser *info = new NaClFileInfoAutoCloser(&tmp_info); 1160 NaClFileInfoAutoCloser *info = new NaClFileInfoAutoCloser(&tmp_info);
1161 1161
1162 if (pp_error != PP_OK) { 1162 if (pp_error != PP_OK) {
1163 PP_RunCompletionCallback(&callback, pp_error); 1163 PP_RunCompletionCallback(&callback, pp_error);
1164 delete info; 1164 delete info;
1165 } else if (info->get_desc() > NACL_NO_FILE_DESC) { 1165 } else if (info->get_desc() > NACL_NO_FILE_DESC) {
1166 std::map<nacl::string, NaClFileInfoAutoCloser*>::iterator it = 1166 std::map<nacl::string, NaClFileInfoAutoCloser*>::iterator it =
1167 url_file_info_map_.find(url_downloader->url_to_open()); 1167 url_file_info_map_.find(url_downloader->url());
1168 if (it != url_file_info_map_.end()) { 1168 if (it != url_file_info_map_.end()) {
1169 delete it->second; 1169 delete it->second;
1170 } 1170 }
1171 url_file_info_map_[url_downloader->url_to_open()] = info; 1171 url_file_info_map_[url_downloader->url()] = info;
1172 PP_RunCompletionCallback(&callback, PP_OK); 1172 PP_RunCompletionCallback(&callback, PP_OK);
1173 } else { 1173 } else {
1174 PP_RunCompletionCallback(&callback, PP_ERROR_FAILED); 1174 PP_RunCompletionCallback(&callback, PP_ERROR_FAILED);
1175 delete info; 1175 delete info;
1176 } 1176 }
1177 } 1177 }
1178 1178
1179 struct NaClFileInfo Plugin::GetFileInfo(const nacl::string& url) { 1179 struct NaClFileInfo Plugin::GetFileInfo(const nacl::string& url) {
1180 struct NaClFileInfo info; 1180 struct NaClFileInfo info;
1181 memset(&info, 0, sizeof(info)); 1181 memset(&info, 0, sizeof(info));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 &UpdateDownloadProgress); 1224 &UpdateDownloadProgress);
1225 } 1225 }
1226 1226
1227 1227
1228 void Plugin::ReportLoadSuccess(LengthComputable length_computable, 1228 void Plugin::ReportLoadSuccess(LengthComputable length_computable,
1229 uint64_t loaded_bytes, 1229 uint64_t loaded_bytes,
1230 uint64_t total_bytes) { 1230 uint64_t total_bytes) {
1231 // Set the readyState attribute to indicate loaded. 1231 // Set the readyState attribute to indicate loaded.
1232 set_nacl_ready_state(DONE); 1232 set_nacl_ready_state(DONE);
1233 // Inform JavaScript that loading was successful and is complete. 1233 // Inform JavaScript that loading was successful and is complete.
1234 const nacl::string& url = nexe_downloader_.url_to_open(); 1234 const nacl::string& url = nexe_downloader_.url();
1235 EnqueueProgressEvent( 1235 EnqueueProgressEvent(
1236 PP_NACL_EVENT_LOAD, url, length_computable, loaded_bytes, total_bytes); 1236 PP_NACL_EVENT_LOAD, url, length_computable, loaded_bytes, total_bytes);
1237 EnqueueProgressEvent( 1237 EnqueueProgressEvent(
1238 PP_NACL_EVENT_LOADEND, url, length_computable, loaded_bytes, total_bytes); 1238 PP_NACL_EVENT_LOADEND, url, length_computable, loaded_bytes, total_bytes);
1239 1239
1240 // UMA 1240 // UMA
1241 HistogramEnumerateLoadStatus(PP_NACL_ERROR_LOAD_SUCCESS, is_installed_); 1241 HistogramEnumerateLoadStatus(PP_NACL_ERROR_LOAD_SUCCESS, is_installed_);
1242 } 1242 }
1243 1243
1244 1244
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 const int64_t kTenMilliseconds = 10000; 1294 const int64_t kTenMilliseconds = 10000;
1295 if (elapsed > kTenMilliseconds) { 1295 if (elapsed > kTenMilliseconds) {
1296 plugin->time_of_last_progress_event_ = time; 1296 plugin->time_of_last_progress_event_ = time;
1297 1297
1298 // Find the URL loader that sent this notification. 1298 // Find the URL loader that sent this notification.
1299 const FileDownloader* file_downloader = 1299 const FileDownloader* file_downloader =
1300 plugin->FindFileDownloader(pp_resource); 1300 plugin->FindFileDownloader(pp_resource);
1301 // If not a streamed file, it must be the .nexe loader. 1301 // If not a streamed file, it must be the .nexe loader.
1302 if (file_downloader == NULL) 1302 if (file_downloader == NULL)
1303 file_downloader = &plugin->nexe_downloader_; 1303 file_downloader = &plugin->nexe_downloader_;
1304 nacl::string url = file_downloader->url_to_open(); 1304 nacl::string url = file_downloader->url();
1305 LengthComputable length_computable = (total_bytes_to_be_received >= 0) ? 1305 LengthComputable length_computable = (total_bytes_to_be_received >= 0) ?
1306 LENGTH_IS_COMPUTABLE : LENGTH_IS_NOT_COMPUTABLE; 1306 LENGTH_IS_COMPUTABLE : LENGTH_IS_NOT_COMPUTABLE;
1307 1307
1308 plugin->EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS, 1308 plugin->EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS,
1309 url, 1309 url,
1310 length_computable, 1310 length_computable,
1311 bytes_received, 1311 bytes_received,
1312 total_bytes_to_be_received); 1312 total_bytes_to_be_received);
1313 } 1313 }
1314 } 1314 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 DCHECK(pp::Module::Get()->core()->IsMainThread()); 1477 DCHECK(pp::Module::Get()->core()->IsMainThread());
1478 DCHECK(nacl_interface_); 1478 DCHECK(nacl_interface_);
1479 exit_status_ = exit_status; 1479 exit_status_ = exit_status;
1480 nacl_interface_->SetReadOnlyProperty(pp_instance(), 1480 nacl_interface_->SetReadOnlyProperty(pp_instance(),
1481 pp::Var("exitStatus").pp_var(), 1481 pp::Var("exitStatus").pp_var(),
1482 pp::Var(exit_status_).pp_var()); 1482 pp::Var(exit_status_).pp_var());
1483 } 1483 }
1484 1484
1485 1485
1486 } // namespace plugin 1486 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/file_downloader.cc ('k') | ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698