OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/feedback_private/feedback_private_api.h" | 5 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/statistics_recorder.h" | 12 #include "base/metrics/statistics_recorder.h" |
11 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 16 #include "base/values.h" |
15 #include "build/build_config.h" | 17 #include "build/build_config.h" |
16 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // The manager is only available if tracing is enabled. | 87 // The manager is only available if tracing is enabled. |
86 if (TracingManager* manager = TracingManager::Get()) { | 88 if (TracingManager* manager = TracingManager::Get()) { |
87 info.trace_id.reset(new int(manager->RequestTrace())); | 89 info.trace_id.reset(new int(manager->RequestTrace())); |
88 } | 90 } |
89 | 91 |
90 scoped_ptr<base::ListValue> args(new base::ListValue()); | 92 scoped_ptr<base::ListValue> args(new base::ListValue()); |
91 args->Append(info.ToValue().release()); | 93 args->Append(info.ToValue().release()); |
92 | 94 |
93 scoped_ptr<Event> event(new Event( | 95 scoped_ptr<Event> event(new Event( |
94 events::FEEDBACK_PRIVATE_ON_FEEDBACK_REQUESTED, | 96 events::FEEDBACK_PRIVATE_ON_FEEDBACK_REQUESTED, |
95 feedback_private::OnFeedbackRequested::kEventName, args.Pass())); | 97 feedback_private::OnFeedbackRequested::kEventName, std::move(args))); |
96 event->restrict_to_browser_context = browser_context_; | 98 event->restrict_to_browser_context = browser_context_; |
97 | 99 |
98 EventRouter::Get(browser_context_) | 100 EventRouter::Get(browser_context_) |
99 ->DispatchEventToExtension(kFeedbackExtensionId, event.Pass()); | 101 ->DispatchEventToExtension(kFeedbackExtensionId, std::move(event)); |
100 } | 102 } |
101 } | 103 } |
102 | 104 |
103 // static | 105 // static |
104 base::Closure* FeedbackPrivateGetStringsFunction::test_callback_ = NULL; | 106 base::Closure* FeedbackPrivateGetStringsFunction::test_callback_ = NULL; |
105 | 107 |
106 bool FeedbackPrivateGetStringsFunction::RunSync() { | 108 bool FeedbackPrivateGetStringsFunction::RunSync() { |
107 base::DictionaryValue* dict = new base::DictionaryValue(); | 109 base::DictionaryValue* dict = new base::DictionaryValue(); |
108 SetResult(dict); | 110 SetResult(dict); |
109 | 111 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 211 } |
210 | 212 |
211 scoped_ptr<FeedbackData::SystemLogsMap> sys_logs( | 213 scoped_ptr<FeedbackData::SystemLogsMap> sys_logs( |
212 new FeedbackData::SystemLogsMap); | 214 new FeedbackData::SystemLogsMap); |
213 SystemInformationList* sys_info = feedback_info.system_information.get(); | 215 SystemInformationList* sys_info = feedback_info.system_information.get(); |
214 if (sys_info) { | 216 if (sys_info) { |
215 for (SystemInformationList::iterator it = sys_info->begin(); | 217 for (SystemInformationList::iterator it = sys_info->begin(); |
216 it != sys_info->end(); ++it) | 218 it != sys_info->end(); ++it) |
217 (*sys_logs.get())[it->get()->key] = it->get()->value; | 219 (*sys_logs.get())[it->get()->key] = it->get()->value; |
218 } | 220 } |
219 feedback_data->SetAndCompressSystemInfo(sys_logs.Pass()); | 221 feedback_data->SetAndCompressSystemInfo(std::move(sys_logs)); |
220 | 222 |
221 FeedbackService* service = | 223 FeedbackService* service = |
222 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); | 224 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); |
223 DCHECK(service); | 225 DCHECK(service); |
224 | 226 |
225 if (feedback_info.send_histograms) { | 227 if (feedback_info.send_histograms) { |
226 scoped_ptr<std::string> histograms(new std::string); | 228 scoped_ptr<std::string> histograms(new std::string); |
227 *histograms = base::StatisticsRecorder::ToJSON(std::string()); | 229 *histograms = base::StatisticsRecorder::ToJSON(std::string()); |
228 if (!histograms->empty()) | 230 if (!histograms->empty()) |
229 feedback_data->SetAndCompressHistograms(histograms.Pass()); | 231 feedback_data->SetAndCompressHistograms(std::move(histograms)); |
230 } | 232 } |
231 | 233 |
232 service->SendFeedback( | 234 service->SendFeedback( |
233 GetProfile(), | 235 GetProfile(), |
234 feedback_data, | 236 feedback_data, |
235 base::Bind(&FeedbackPrivateSendFeedbackFunction::OnCompleted, this)); | 237 base::Bind(&FeedbackPrivateSendFeedbackFunction::OnCompleted, this)); |
236 | 238 |
237 return true; | 239 return true; |
238 } | 240 } |
239 | 241 |
240 void FeedbackPrivateSendFeedbackFunction::OnCompleted( | 242 void FeedbackPrivateSendFeedbackFunction::OnCompleted( |
241 bool success) { | 243 bool success) { |
242 results_ = feedback_private::SendFeedback::Results::Create( | 244 results_ = feedback_private::SendFeedback::Results::Create( |
243 success ? feedback_private::STATUS_SUCCESS : | 245 success ? feedback_private::STATUS_SUCCESS : |
244 feedback_private::STATUS_DELAYED); | 246 feedback_private::STATUS_DELAYED); |
245 SendResponse(true); | 247 SendResponse(true); |
246 } | 248 } |
247 | 249 |
248 } // namespace extensions | 250 } // namespace extensions |
OLD | NEW |