| Index: chrome/browser/ui/webui/chromeos/system_info_ui.cc
|
| diff --git a/chrome/browser/ui/webui/chromeos/system_info_ui.cc b/chrome/browser/ui/webui/chromeos/system_info_ui.cc
|
| index 2c0d944bd74be319f76e0e18b9ae563b5fff7991..19a6d103582f387d8417cd4ccf1347dbd68b2742 100644
|
| --- a/chrome/browser/ui/webui/chromeos/system_info_ui.cc
|
| +++ b/chrome/browser/ui/webui/chromeos/system_info_ui.cc
|
| @@ -18,8 +18,7 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/chromeos/cros/cros_library.h"
|
| -#include "chrome/browser/chromeos/system/sysinfo_provider.h"
|
| -#include "chrome/browser/chromeos/system/syslogs_provider.h"
|
| +#include "chrome/browser/chromeos/syslogs/syslogs_fetcher.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
|
| #include "chrome/common/chrome_paths.h"
|
| @@ -58,24 +57,16 @@ class SystemInfoUIHTMLSource : public ChromeURLDataManager::DataSource {
|
| private:
|
| ~SystemInfoUIHTMLSource() {}
|
|
|
| - void SyslogsComplete(chromeos::system::LogDictionaryType* sys_info,
|
| - std::string* ignored_content);
|
| - void SysInfoComplete(chromeos::system::SysInfoResponse* response);
|
| + void SysInfoComplete(chromeos::SysLogsResponse* response);
|
| void RequestComplete();
|
| void WaitForData();
|
|
|
| - CancelableRequestConsumer logs_consumer_;
|
| - CancelableRequestConsumer sys_info_consumer_;
|
| -
|
| // Stored data from StartDataRequest()
|
| std::string path_;
|
| int request_id_;
|
|
|
| - int pending_requests_;
|
| - chromeos::system::LogDictionaryType* logs_;
|
| - chromeos::system::SysInfoResponse* sys_info_;
|
| - scoped_ptr<chromeos::system::SysInfoProvider> sys_info_provider_;
|
| -
|
| + chromeos::SysLogsResponse* sys_info_;
|
| + base::WeakPtrFactory<SystemInfoUIHTMLSource> weak_ptr_factory_;
|
| DISALLOW_COPY_AND_ASSIGN(SystemInfoUIHTMLSource);
|
| };
|
|
|
| @@ -101,8 +92,8 @@ class SystemInfoHandler : public WebUIMessageHandler,
|
|
|
| SystemInfoUIHTMLSource::SystemInfoUIHTMLSource()
|
| : DataSource(chrome::kChromeUISystemInfoHost, MessageLoop::current()),
|
| - request_id_(0), logs_(NULL), sys_info_(NULL),
|
| - sys_info_provider_(chromeos::system::SysInfoProvider::Create()) {
|
| + request_id_(0), sys_info_(NULL),
|
| + ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
|
| }
|
|
|
| void SystemInfoUIHTMLSource::StartDataRequest(const std::string& path,
|
| @@ -110,44 +101,22 @@ void SystemInfoUIHTMLSource::StartDataRequest(const std::string& path,
|
| int request_id) {
|
| path_ = path;
|
| request_id_ = request_id;
|
| - pending_requests_ = 0;
|
| -
|
| - chromeos::system::SyslogsProvider* provider =
|
| - chromeos::system::SyslogsProvider::GetInstance();
|
| - if (provider) {
|
| - provider->RequestSyslogs(
|
| - false, // don't compress.
|
| - chromeos::system::SyslogsProvider::SYSLOGS_SYSINFO,
|
| - &logs_consumer_,
|
| - base::Bind(&SystemInfoUIHTMLSource::SyslogsComplete,
|
| - base::Unretained(this)));
|
| - pending_requests_++;
|
| - }
|
|
|
| - sys_info_provider_->Fetch(&sys_info_consumer_,
|
| - base::Bind(
|
| - &SystemInfoUIHTMLSource::SysInfoComplete,
|
| - base::Unretained(this)));
|
| - pending_requests_++;
|
| -}
|
| + chromeos::SysLogsFetcher * fetcher = new chromeos::SysLogsFetcher();
|
| + fetcher->Fetch(base::Bind(
|
| + &SystemInfoUIHTMLSource::SysInfoComplete,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
|
|
| -void SystemInfoUIHTMLSource::SyslogsComplete(
|
| - chromeos::system::LogDictionaryType* sys_info,
|
| - std::string* ignored_content) {
|
| - logs_ = sys_info;
|
| - RequestComplete();
|
| }
|
|
|
| +
|
| void SystemInfoUIHTMLSource::SysInfoComplete(
|
| - chromeos::system::SysInfoResponse* sys_info) {
|
| + chromeos::SysLogsResponse* sys_info) {
|
| sys_info_ = sys_info;
|
| RequestComplete();
|
| }
|
|
|
| void SystemInfoUIHTMLSource::RequestComplete() {
|
| - if (--pending_requests_)
|
| - return;
|
| -
|
| DictionaryValue strings;
|
| strings.SetString("title", l10n_util::GetStringUTF16(IDS_ABOUT_SYS_TITLE));
|
| strings.SetString("description",
|
| @@ -163,35 +132,19 @@ void SystemInfoUIHTMLSource::RequestComplete() {
|
| strings.SetString("collapse_btn",
|
| l10n_util::GetStringUTF16(IDS_ABOUT_SYS_COLLAPSE));
|
| SetFontAndTextDirection(&strings);
|
| -
|
| - if (logs_ || sys_info_) {
|
| + if (sys_info_)
|
| + {
|
| ListValue* details = new ListValue();
|
| strings.Set("details", details);
|
| - if (logs_) {
|
| - chromeos::system::LogDictionaryType::iterator it;
|
| - for (it = logs_->begin(); it != logs_->end(); ++it) {
|
| - DictionaryValue* val = new DictionaryValue;
|
| - val->SetString("stat_name", it->first);
|
| - val->SetString("stat_value", it->second);
|
| - details->Append(val);
|
| - }
|
| - delete logs_;
|
| - }
|
| - if (sys_info_) {
|
| - chromeos::system::SysInfoResponse::iterator it;
|
| - for (it = sys_info_->begin(); it != sys_info_->end(); ++it) {
|
| - DictionaryValue* val = new DictionaryValue;
|
| - // Prefix stats coming from debugd with 'debugd-' for now. The code that
|
| - // displays stats can only handle one stat with a given name, so this
|
| - // prevents names from overlapping. Once the duplicates have been
|
| - // removed from userfeedback's list by
|
| - // <https://gerrit.chromium.org/gerrit/25106>, the prefix can go away.
|
| - val->SetString("stat_name", "debugd-" + it->first);
|
| - val->SetString("stat_value", it->second);
|
| - details->Append(val);
|
| - }
|
| - delete sys_info_;
|
| +
|
| + chromeos::SysLogsResponse::iterator it;
|
| + for (it = sys_info_->begin(); it != sys_info_->end(); ++it) {
|
| + DictionaryValue* val = new DictionaryValue;
|
| + val->SetString("stat_name", it->first);
|
| + val->SetString("stat_value", it->second);
|
| + details->Append(val);
|
| }
|
| + delete sys_info_;
|
| strings.SetString("anchor", path_);
|
| }
|
| static const base::StringPiece systeminfo_html(
|
| @@ -199,7 +152,6 @@ void SystemInfoUIHTMLSource::RequestComplete() {
|
| IDR_ABOUT_SYS_HTML, ui::SCALE_FACTOR_NONE));
|
| std::string full_html = jstemplate_builder::GetTemplatesHtml(
|
| systeminfo_html, &strings, "t" /* template root node id */);
|
| -
|
| SendResponse(request_id_, base::RefCountedString::TakeString(&full_html));
|
| }
|
|
|
|
|