| OLD | NEW |
| 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 #include "chrome/browser/ui/webui/version_handler_chromeos.h" | 5 #include "chrome/browser/ui/webui/version_handler_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/task_runner_util.h" | 8 #include "base/task_scheduler/post_task.h" |
| 9 #include "content/public/browser/browser_thread.h" | |
| 10 #include "content/public/browser/web_ui.h" | 9 #include "content/public/browser/web_ui.h" |
| 11 | 10 |
| 12 VersionHandlerChromeOS::VersionHandlerChromeOS() | 11 VersionHandlerChromeOS::VersionHandlerChromeOS() |
| 13 : weak_factory_(this) { | 12 : weak_factory_(this) { |
| 14 } | 13 } |
| 15 | 14 |
| 16 VersionHandlerChromeOS::~VersionHandlerChromeOS() { | 15 VersionHandlerChromeOS::~VersionHandlerChromeOS() { |
| 17 } | 16 } |
| 18 | 17 |
| 19 void VersionHandlerChromeOS::HandleRequestVersionInfo( | 18 void VersionHandlerChromeOS::HandleRequestVersionInfo( |
| 20 const base::ListValue* args) { | 19 const base::ListValue* args) { |
| 21 // Start the asynchronous load of the versions. | 20 // Start the asynchronous load of the versions. |
| 22 base::PostTaskAndReplyWithResult( | 21 base::PostTaskWithTraitsAndReplyWithResult( |
| 23 content::BrowserThread::GetBlockingPool(), | 22 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( |
| 24 FROM_HERE, | 23 base::TaskPriority::BACKGROUND), |
| 25 base::Bind(&chromeos::version_loader::GetVersion, | 24 base::Bind(&chromeos::version_loader::GetVersion, |
| 26 chromeos::version_loader::VERSION_FULL), | 25 chromeos::version_loader::VERSION_FULL), |
| 27 base::Bind(&VersionHandlerChromeOS::OnVersion, | 26 base::Bind(&VersionHandlerChromeOS::OnVersion, |
| 28 weak_factory_.GetWeakPtr())); | 27 weak_factory_.GetWeakPtr())); |
| 29 base::PostTaskAndReplyWithResult( | 28 base::PostTaskWithTraitsAndReplyWithResult( |
| 30 content::BrowserThread::GetBlockingPool(), | 29 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( |
| 31 FROM_HERE, | 30 base::TaskPriority::BACKGROUND), |
| 32 base::Bind(&chromeos::version_loader::GetARCVersion), | 31 base::Bind(&chromeos::version_loader::GetARCVersion), |
| 33 base::Bind(&VersionHandlerChromeOS::OnARCVersion, | 32 base::Bind(&VersionHandlerChromeOS::OnARCVersion, |
| 34 weak_factory_.GetWeakPtr())); | 33 weak_factory_.GetWeakPtr())); |
| 35 | 34 |
| 36 // Parent class takes care of the rest. | 35 // Parent class takes care of the rest. |
| 37 VersionHandler::HandleRequestVersionInfo(args); | 36 VersionHandler::HandleRequestVersionInfo(args); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void VersionHandlerChromeOS::OnVersion(const std::string& version) { | 39 void VersionHandlerChromeOS::OnVersion(const std::string& version) { |
| 41 base::StringValue arg(version); | 40 base::StringValue arg(version); |
| 42 web_ui()->CallJavascriptFunctionUnsafe("returnOsVersion", arg); | 41 web_ui()->CallJavascriptFunctionUnsafe("returnOsVersion", arg); |
| 43 } | 42 } |
| 44 | 43 |
| 45 void VersionHandlerChromeOS::OnARCVersion(const std::string& version) { | 44 void VersionHandlerChromeOS::OnARCVersion(const std::string& version) { |
| 46 base::StringValue arg(version); | 45 base::StringValue arg(version); |
| 47 web_ui()->CallJavascriptFunctionUnsafe("returnARCVersion", arg); | 46 web_ui()->CallJavascriptFunctionUnsafe("returnARCVersion", arg); |
| 48 } | 47 } |
| OLD | NEW |