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

Unified Diff: chrome/browser/ui/webui/nacl_ui.cc

Issue 56833003: Use base::PostTaskAndReplyWithResults() in more places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix clang error Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/nacl_ui.cc
diff --git a/chrome/browser/ui/webui/nacl_ui.cc b/chrome/browser/ui/webui/nacl_ui.cc
index 62be1041f18d2f12a961f765ee144eee4eef4908..856557bca87c32769e2f1216b8edd65099e26800 100644
--- a/chrome/browser/ui/webui/nacl_ui.cc
+++ b/chrome/browser/ui/webui/nacl_ui.cc
@@ -88,7 +88,7 @@ class NaClDomHandler : public WebUIMessageHandler {
// A helper callback that receives the result of checking if PNaCl path
// exists and checking the PNaCl |version|. |is_valid| is true if the PNaCl
// path that was returned by PathService is valid, and false otherwise.
- void DidCheckPathAndVersion(bool* is_valid, std::string* version);
+ void DidCheckPathAndVersion(const std::string* version, bool is_valid);
// Called when enough information is gathered to return data back to the page.
void MaybeRespondToPage();
@@ -318,17 +318,17 @@ void NaClDomHandler::PopulatePageInformation(DictionaryValue* naclInfo) {
naclInfo->Set("naclInfo", list.release());
}
-void NaClDomHandler::DidCheckPathAndVersion(bool* is_valid,
- std::string* version) {
+void NaClDomHandler::DidCheckPathAndVersion(const std::string* version,
+ bool is_valid) {
pnacl_path_validated_ = true;
- pnacl_path_exists_ = *is_valid;
+ pnacl_path_exists_ = is_valid;
pnacl_version_string_ = *version;
MaybeRespondToPage();
}
void CheckVersion(const base::FilePath& pnacl_path, std::string* version) {
base::FilePath pnacl_json_path =
- pnacl_path.Append(FILE_PATH_LITERAL("pnacl_public_pnacl_json"));
+ pnacl_path.AppendASCII("pnacl_public_pnacl_json");
JSONFileValueSerializer serializer(pnacl_json_path);
std::string error;
scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error));
@@ -337,16 +337,18 @@ void CheckVersion(const base::FilePath& pnacl_path, std::string* version) {
// Now try to get the field. This may leave version empty if the
// the "get" fails (no key, or wrong type).
- static_cast<base::DictionaryValue*>(root.get())->
- GetStringASCII("pnacl-version", version);
+ static_cast<base::DictionaryValue*>(root.get())->GetStringASCII(
+ "pnacl-version", version);
}
-void CheckPathAndVersion(bool* is_valid, std::string* version) {
+bool CheckPathAndVersion(std::string* version) {
base::FilePath pnacl_path;
bool got_path = PathService::Get(chrome::DIR_PNACL_COMPONENT, &pnacl_path);
- *is_valid = got_path && !pnacl_path.empty() && base::PathExists(pnacl_path);
- if (*is_valid)
+ if (got_path && !pnacl_path.empty() && base::PathExists(pnacl_path)) {
CheckVersion(pnacl_path, version);
+ return true;
+ }
+ return false;
}
void NaClDomHandler::MaybeRespondToPage() {
@@ -356,14 +358,13 @@ void NaClDomHandler::MaybeRespondToPage() {
return;
if (!pnacl_path_validated_) {
- bool* is_valid = new bool;
std::string* version_string = new std::string;
- BrowserThread::PostBlockingPoolTaskAndReply(
+ base::PostTaskAndReplyWithResult(
+ BrowserThread::GetBlockingPool(),
FROM_HERE,
- base::Bind(&CheckPathAndVersion, is_valid, version_string),
+ base::Bind(&CheckPathAndVersion, version_string),
base::Bind(&NaClDomHandler::DidCheckPathAndVersion,
weak_ptr_factory_.GetWeakPtr(),
- base::Owned(is_valid),
base::Owned(version_string)));
return;
}
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_error_handler.cc ('k') | components/nacl/browser/nacl_browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698