diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-01 06:00:53 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-01 06:00:53 +0000 |
commit | b8903e50f463e5c09d94775d7a684485d32caff1 (patch) | |
tree | ff2dc5706589cf1a1422849f1a0df65b3f301c5a /ppapi/native_client | |
parent | bebe8a3f3d580c9e270e07304f57c63c444a4d6c (diff) | |
download | chromium_src-b8903e50f463e5c09d94775d7a684485d32caff1.zip chromium_src-b8903e50f463e5c09d94775d7a684485d32caff1.tar.gz chromium_src-b8903e50f463e5c09d94775d7a684485d32caff1.tar.bz2 |
NaCl: Simplify callback calls in FileDownloader.
BUG=
Review URL: https://codereview.chromium.org/25098003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226159 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client')
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/file_downloader.cc | 29 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/file_downloader.h | 2 |
2 files changed, 11 insertions, 20 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/file_downloader.cc b/ppapi/native_client/src/trusted/plugin/file_downloader.cc index 0a75407..21f7075 100644 --- a/ppapi/native_client/src/trusted/plugin/file_downloader.cc +++ b/ppapi/native_client/src/trusted/plugin/file_downloader.cc @@ -33,7 +33,7 @@ struct NaClFileInfo NoFileInfo() { return info; } -} +} // namespace namespace plugin { @@ -212,18 +212,12 @@ int64_t FileDownloader::TimeSinceOpenMilliseconds() const { return (now - open_time_) / NACL_MICROS_PER_MILLI; } -bool FileDownloader::InitialResponseIsValid(int32_t pp_error) { - if (pp_error != PP_OK) { // Url loading failed. - file_open_notify_callback_.RunAndClear(pp_error); - return false; - } - +bool FileDownloader::InitialResponseIsValid() { // Process the response, validating the headers to confirm successful loading. url_response_ = url_loader_.GetResponseInfo(); if (url_response_.is_null()) { PLUGIN_PRINTF(( "FileDownloader::InitialResponseIsValid (url_response_=NULL)\n")); - file_open_notify_callback_.RunAndClear(PP_ERROR_FAILED); return false; } @@ -231,7 +225,6 @@ bool FileDownloader::InitialResponseIsValid(int32_t pp_error) { if (!full_url.is_string()) { PLUGIN_PRINTF(( "FileDownloader::InitialResponseIsValid (url is not a string)\n")); - file_open_notify_callback_.RunAndClear(PP_ERROR_FAILED); return false; } url_ = full_url.AsString(); @@ -259,28 +252,26 @@ bool FileDownloader::InitialResponseIsValid(int32_t pp_error) { status_ok = (status_code_ == NACL_HTTP_STATUS_OK); break; } - - if (!status_ok) { - file_open_notify_callback_.RunAndClear(PP_ERROR_FAILED); - return false; - } - - return true; + return status_ok; } void FileDownloader::URLLoadStartNotify(int32_t pp_error) { PLUGIN_PRINTF(("FileDownloader::URLLoadStartNotify (pp_error=%" NACL_PRId32")\n", pp_error)); + if (pp_error != PP_OK) { + file_open_notify_callback_.RunAndClear(pp_error); + return; + } - if (!InitialResponseIsValid(pp_error)) { - // InitialResponseIsValid() calls file_open_notify_callback_ on errors. + if (!InitialResponseIsValid()) { + file_open_notify_callback_.RunAndClear(PP_ERROR_FAILED); return; } if (open_and_stream_) return FinishStreaming(file_open_notify_callback_); - file_open_notify_callback_.RunAndClear(pp_error); + file_open_notify_callback_.RunAndClear(PP_OK); } void FileDownloader::FinishStreaming( diff --git a/ppapi/native_client/src/trusted/plugin/file_downloader.h b/ppapi/native_client/src/trusted/plugin/file_downloader.h index 5fc509a..c0045ed 100644 --- a/ppapi/native_client/src/trusted/plugin/file_downloader.h +++ b/ppapi/native_client/src/trusted/plugin/file_downloader.h @@ -165,7 +165,7 @@ class FileDownloader { // data is passed directly to the user instead of saved in a buffer. // The public Open*() functions start step 1), and the public FinishStreaming // function proceeds to step 2) and 3). - bool InitialResponseIsValid(int32_t pp_error); + bool InitialResponseIsValid(); void URLLoadStartNotify(int32_t pp_error); void URLLoadFinishNotify(int32_t pp_error); void URLReadBodyNotify(int32_t pp_error); |