summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-21 22:43:32 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-21 22:43:32 +0000
commita39a674e796f7f61a3a97b38cdd32a91fb1825ec (patch)
tree80b23377002c5594bfa1b4c5cfaeea9c94feaa39 /ppapi
parent4c047c062cc1ab83956ef51013a6d443baaa0f74 (diff)
downloadchromium_src-a39a674e796f7f61a3a97b38cdd32a91fb1825ec.zip
chromium_src-a39a674e796f7f61a3a97b38cdd32a91fb1825ec.tar.gz
chromium_src-a39a674e796f7f61a3a97b38cdd32a91fb1825ec.tar.bz2
Pepper: Drop open time tracking from FileDownloader.
This change reduces the size of the FileDownloader interface as part of moving FileDownloader logic out of the trusted plugin. BUG=239656 Review URL: https://codereview.chromium.org/245483002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265102 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/native_client/src/trusted/plugin/file_downloader.cc13
-rw-r--r--ppapi/native_client/src/trusted/plugin/file_downloader.h7
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.cc21
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.h4
4 files changed, 23 insertions, 22 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/file_downloader.cc b/ppapi/native_client/src/trusted/plugin/file_downloader.cc
index 8b72ede..1118e1d 100644
--- a/ppapi/native_client/src/trusted/plugin/file_downloader.cc
+++ b/ppapi/native_client/src/trusted/plugin/file_downloader.cc
@@ -122,7 +122,6 @@ bool FileDownloader::Open(
return false;
CHECK(instance_ != NULL);
- open_time_ = NaClGetTimeOfDayMicroseconds();
status_code_ = -1;
url_ = url;
file_open_notify_callback_ = callback;
@@ -145,8 +144,6 @@ bool FileDownloader::Open(
// Note that we have the only reference to the underlying objects, so
// this will implicitly close any pending IO and destroy them.
url_loader_ = pp::URLLoader(instance_);
- pp::Var url_var = pp::Var(url);
- url_scheme_ = instance_->nacl_interface()->GetUrlScheme(url_var.pp_var());
url_request.SetRecordDownloadProgress(record_progress);
@@ -185,7 +182,6 @@ void FileDownloader::OpenFast(const nacl::string& url,
file_info_.FreeResources();
CHECK(instance_ != NULL);
- open_time_ = NaClGetTimeOfDayMicroseconds();
status_code_ = NACL_HTTP_STATUS_OK;
url_ = url;
mode_ = DOWNLOAD_NONE;
@@ -210,15 +206,6 @@ NaClFileInfo FileDownloader::GetFileInfo() {
return info_to_return;
}
-int64_t FileDownloader::TimeSinceOpenMilliseconds() const {
- int64_t now = NaClGetTimeOfDayMicroseconds();
- // If Open() wasn't called or we somehow return an earlier time now, just
- // return the 0 rather than worse nonsense values.
- if (open_time_ < 0 || now < open_time_)
- return 0;
- return (now - open_time_) / NACL_MICROS_PER_MILLI;
-}
-
bool FileDownloader::InitialResponseIsValid() {
// Process the response, validating the headers to confirm successful loading.
url_response_ = url_loader_.GetResponseInfo();
diff --git a/ppapi/native_client/src/trusted/plugin/file_downloader.h b/ppapi/native_client/src/trusted/plugin/file_downloader.h
index 2c43a56..fa70a70 100644
--- a/ppapi/native_client/src/trusted/plugin/file_downloader.h
+++ b/ppapi/native_client/src/trusted/plugin/file_downloader.h
@@ -78,9 +78,7 @@ class FileDownloader {
stream_finish_callback_(pp::BlockUntilComplete()),
file_io_private_interface_(NULL),
url_loader_trusted_interface_(NULL),
- open_time_(-1),
mode_(DOWNLOAD_NONE),
- url_scheme_(PP_SCHEME_OTHER),
data_stream_callback_source_(NULL) {}
~FileDownloader() {}
@@ -132,9 +130,6 @@ class FileDownloader {
// delegate does not have to close it.
struct NaClFileInfo GetFileInfo();
- // Returns the time delta between the call to Open() and this function.
- int64_t TimeSinceOpenMilliseconds() const;
-
// Returns the url passed to Open().
const nacl::string& url() const { return url_; }
@@ -202,12 +197,10 @@ class FileDownloader {
const PPB_URLLoaderTrusted* url_loader_trusted_interface_;
pp::URLLoader url_loader_;
pp::CompletionCallbackFactory<FileDownloader> callback_factory_;
- int64_t open_time_;
int32_t status_code_;
DownloadMode mode_;
static const uint32_t kTempBufferSize = 16384;
std::vector<char> temp_buffer_;
- PP_UrlSchemeType url_scheme_;
StreamCallbackSource* data_stream_callback_source_;
NaClFileInfoAutoCloser file_info_;
};
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc
index a2be3d5..47640a2 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc
@@ -492,6 +492,8 @@ Plugin::Plugin(PP_Instance pp_instance)
wrapper_factory_(NULL),
enable_dev_interfaces_(false),
time_of_last_progress_event_(0),
+ manifest_open_time_(-1),
+ nexe_open_time_(-1),
nacl_interface_(NULL),
uma_interface_(this) {
PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%"
@@ -585,6 +587,13 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) {
nexe_bytes_read = stat_buf.st_size;
}
+ int64_t now = NaClGetTimeOfDayMicroseconds();
+ int64_t download_time;
+ if (now < nexe_open_time_)
+ download_time = 0;
+ else
+ download_time = now - nexe_open_time_;
+
nacl_interface_->NexeFileDidOpen(
pp_instance(),
pp_error,
@@ -592,7 +601,7 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) {
nexe_downloader_.status_code(),
nexe_bytes_read,
nexe_downloader_.url().c_str(),
- nexe_downloader_.TimeSinceOpenMilliseconds());
+ download_time / 1000);
if (nexe_bytes_read == -1)
return;
@@ -679,8 +688,14 @@ void Plugin::BitcodeDidTranslateContinuation(int32_t pp_error) {
void Plugin::NaClManifestFileDidOpen(int32_t pp_error) {
PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (pp_error=%"
NACL_PRId32 ")\n", pp_error));
+ int64_t now = NaClGetTimeOfDayMicroseconds();
+ int64_t download_time;
+ if (now < manifest_open_time_)
+ download_time = 0;
+ else
+ download_time = now - manifest_open_time_;
HistogramTimeSmall("NaCl.Perf.StartupTime.ManifestDownload",
- nexe_downloader_.TimeSinceOpenMilliseconds());
+ download_time / 1000);
HistogramHTTPStatusCode(
nacl_interface_->GetIsInstalled(pp_instance()) ?
"NaCl.HttpStatusCodeClass.Manifest.InstalledApp" :
@@ -779,6 +794,7 @@ void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) {
translate_callback));
return;
} else {
+ nexe_open_time_ = NaClGetTimeOfDayMicroseconds();
// Try the fast path first. This will only block if the file is installed.
if (OpenURLFast(program_url, &nexe_downloader_)) {
NexeFileDidOpen(PP_OK);
@@ -829,6 +845,7 @@ void Plugin::RequestNaClManifest(const nacl::string& url) {
} else {
pp::CompletionCallback open_callback =
callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen);
+ manifest_open_time_ = NaClGetTimeOfDayMicroseconds();
// Will always call the callback on success or failure.
CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(),
DOWNLOAD_TO_FILE,
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h
index 29aa74d..59e7ca8 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.h
+++ b/ppapi/native_client/src/trusted/plugin/plugin.h
@@ -398,6 +398,10 @@ class Plugin : public pp::Instance {
int64_t time_of_last_progress_event_;
int exit_status_;
+ // Open times are in microseconds.
+ int64_t manifest_open_time_;
+ int64_t nexe_open_time_;
+
const PPB_NaCl_Private* nacl_interface_;
pp::UMAPrivate uma_interface_;
};