| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/app_mode/kiosk_diagnosis_runner.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_diagnosis_runner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 content::BrowserThread::UI, | 75 content::BrowserThread::UI, |
| 76 FROM_HERE, | 76 FROM_HERE, |
| 77 base::Bind(&KioskDiagnosisRunner::StartSystemLogCollection, | 77 base::Bind(&KioskDiagnosisRunner::StartSystemLogCollection, |
| 78 weak_factory_.GetWeakPtr()), | 78 weak_factory_.GetWeakPtr()), |
| 79 base::TimeDelta::FromMinutes(1)); | 79 base::TimeDelta::FromMinutes(1)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void KioskDiagnosisRunner::StartSystemLogCollection() { | 82 void KioskDiagnosisRunner::StartSystemLogCollection() { |
| 83 extensions::FeedbackService* service = | 83 extensions::FeedbackService* service = |
| 84 extensions::FeedbackPrivateAPI::GetFactoryInstance() | 84 extensions::FeedbackPrivateAPI::GetFactoryInstance() |
| 85 ->GetForProfile(profile_) | 85 ->Get(profile_) |
| 86 ->GetService(); | 86 ->GetService(); |
| 87 DCHECK(service); | 87 DCHECK(service); |
| 88 | 88 |
| 89 service->GetSystemInformation( | 89 service->GetSystemInformation( |
| 90 base::Bind(&KioskDiagnosisRunner::SendSysLogFeedback, | 90 base::Bind(&KioskDiagnosisRunner::SendSysLogFeedback, |
| 91 weak_factory_.GetWeakPtr())); | 91 weak_factory_.GetWeakPtr())); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void KioskDiagnosisRunner::SendSysLogFeedback( | 94 void KioskDiagnosisRunner::SendSysLogFeedback( |
| 95 const extensions::SystemInformationList& sys_info) { | 95 const extensions::SystemInformationList& sys_info) { |
| 96 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); | 96 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); |
| 97 | 97 |
| 98 feedback_data->set_profile(profile_); | 98 feedback_data->set_profile(profile_); |
| 99 feedback_data->set_description(base::StringPrintf( | 99 feedback_data->set_description(base::StringPrintf( |
| 100 "Autogenerated feedback:\nAppId: %s\n(uniquifier:%s)", | 100 "Autogenerated feedback:\nAppId: %s\n(uniquifier:%s)", |
| 101 app_id_.c_str(), | 101 app_id_.c_str(), |
| 102 base::Int64ToString(base::Time::Now().ToInternalValue()).c_str())); | 102 base::Int64ToString(base::Time::Now().ToInternalValue()).c_str())); |
| 103 | 103 |
| 104 scoped_ptr<FeedbackData::SystemLogsMap> sys_logs( | 104 scoped_ptr<FeedbackData::SystemLogsMap> sys_logs( |
| 105 new FeedbackData::SystemLogsMap); | 105 new FeedbackData::SystemLogsMap); |
| 106 for (extensions::SystemInformationList::const_iterator it = sys_info.begin(); | 106 for (extensions::SystemInformationList::const_iterator it = sys_info.begin(); |
| 107 it != sys_info.end(); ++it) { | 107 it != sys_info.end(); ++it) { |
| 108 (*sys_logs.get())[it->get()->key] = it->get()->value; | 108 (*sys_logs.get())[it->get()->key] = it->get()->value; |
| 109 } | 109 } |
| 110 feedback_data->SetAndCompressSystemInfo(sys_logs.Pass()); | 110 feedback_data->SetAndCompressSystemInfo(sys_logs.Pass()); |
| 111 | 111 |
| 112 extensions::FeedbackService* service = | 112 extensions::FeedbackService* service = |
| 113 extensions::FeedbackPrivateAPI::GetFactoryInstance() | 113 extensions::FeedbackPrivateAPI::GetFactoryInstance() |
| 114 ->GetForProfile(profile_) | 114 ->Get(profile_) |
| 115 ->GetService(); | 115 ->GetService(); |
| 116 DCHECK(service); | 116 DCHECK(service); |
| 117 service->SendFeedback(profile_, | 117 service->SendFeedback(profile_, |
| 118 feedback_data, | 118 feedback_data, |
| 119 base::Bind(&KioskDiagnosisRunner::OnFeedbackSent, | 119 base::Bind(&KioskDiagnosisRunner::OnFeedbackSent, |
| 120 weak_factory_.GetWeakPtr())); | 120 weak_factory_.GetWeakPtr())); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void KioskDiagnosisRunner::OnFeedbackSent(bool) { | 123 void KioskDiagnosisRunner::OnFeedbackSent(bool) { |
| 124 // Do nothing. | 124 // Do nothing. |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace chromeos | 127 } // namespace chromeos |
| OLD | NEW |