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

Side by Side Diff: chrome/browser/extensions/api/feedback_private/feedback_private_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 unified diff | Download patch
OLDNEW
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 <memory>
7 #include <utility> 8 #include <utility>
8 9
9 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/metrics/statistics_recorder.h" 13 #include "base/metrics/statistics_recorder.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h" 20 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/signin/signin_manager_factory.h" 22 #include "chrome/browser/signin/signin_manager_factory.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 86 }
86 87
87 void FeedbackPrivateAPI::RequestFeedbackForFlow( 88 void FeedbackPrivateAPI::RequestFeedbackForFlow(
88 const std::string& description_template, 89 const std::string& description_template,
89 const std::string& category_tag, 90 const std::string& category_tag,
90 const GURL& page_url, 91 const GURL& page_url,
91 api::feedback_private::FeedbackFlow flow) { 92 api::feedback_private::FeedbackFlow flow) {
92 if (browser_context_ && EventRouter::Get(browser_context_)) { 93 if (browser_context_ && EventRouter::Get(browser_context_)) {
93 FeedbackInfo info; 94 FeedbackInfo info;
94 info.description = description_template; 95 info.description = description_template;
95 info.category_tag = make_scoped_ptr(new std::string(category_tag)); 96 info.category_tag = base::WrapUnique(new std::string(category_tag));
96 info.page_url = make_scoped_ptr(new std::string(page_url.spec())); 97 info.page_url = base::WrapUnique(new std::string(page_url.spec()));
97 info.system_information.reset(new SystemInformationList); 98 info.system_information.reset(new SystemInformationList);
98 // The manager is only available if tracing is enabled. 99 // The manager is only available if tracing is enabled.
99 if (TracingManager* manager = TracingManager::Get()) { 100 if (TracingManager* manager = TracingManager::Get()) {
100 info.trace_id.reset(new int(manager->RequestTrace())); 101 info.trace_id.reset(new int(manager->RequestTrace()));
101 } 102 }
102 info.flow = flow; 103 info.flow = flow;
103 104
104 scoped_ptr<base::ListValue> args = 105 std::unique_ptr<base::ListValue> args =
105 feedback_private::OnFeedbackRequested::Create(info); 106 feedback_private::OnFeedbackRequested::Create(info);
106 107
107 scoped_ptr<Event> event(new Event( 108 std::unique_ptr<Event> event(new Event(
108 events::FEEDBACK_PRIVATE_ON_FEEDBACK_REQUESTED, 109 events::FEEDBACK_PRIVATE_ON_FEEDBACK_REQUESTED,
109 feedback_private::OnFeedbackRequested::kEventName, std::move(args))); 110 feedback_private::OnFeedbackRequested::kEventName, std::move(args)));
110 event->restrict_to_browser_context = browser_context_; 111 event->restrict_to_browser_context = browser_context_;
111 112
112 EventRouter::Get(browser_context_) 113 EventRouter::Get(browser_context_)
113 ->DispatchEventToExtension(extension_misc::kFeedbackExtensionId, 114 ->DispatchEventToExtension(extension_misc::kFeedbackExtensionId,
114 std::move(event)); 115 std::move(event));
115 } 116 }
116 } 117 }
117 118
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 185 }
185 186
186 void FeedbackPrivateGetSystemInformationFunction::OnCompleted( 187 void FeedbackPrivateGetSystemInformationFunction::OnCompleted(
187 const SystemInformationList& sys_info) { 188 const SystemInformationList& sys_info) {
188 results_ = feedback_private::GetSystemInformation::Results::Create( 189 results_ = feedback_private::GetSystemInformation::Results::Create(
189 sys_info); 190 sys_info);
190 SendResponse(true); 191 SendResponse(true);
191 } 192 }
192 193
193 bool FeedbackPrivateSendFeedbackFunction::RunAsync() { 194 bool FeedbackPrivateSendFeedbackFunction::RunAsync() {
194 scoped_ptr<feedback_private::SendFeedback::Params> params( 195 std::unique_ptr<feedback_private::SendFeedback::Params> params(
195 feedback_private::SendFeedback::Params::Create(*args_)); 196 feedback_private::SendFeedback::Params::Create(*args_));
196 EXTENSION_FUNCTION_VALIDATE(params.get()); 197 EXTENSION_FUNCTION_VALIDATE(params.get());
197 198
198 const FeedbackInfo &feedback_info = params->feedback; 199 const FeedbackInfo &feedback_info = params->feedback;
199 200
200 std::string attached_file_uuid; 201 std::string attached_file_uuid;
201 if (feedback_info.attached_file_blob_uuid.get() && 202 if (feedback_info.attached_file_blob_uuid.get() &&
202 !feedback_info.attached_file_blob_uuid->empty()) 203 !feedback_info.attached_file_blob_uuid->empty())
203 attached_file_uuid = *feedback_info.attached_file_blob_uuid; 204 attached_file_uuid = *feedback_info.attached_file_blob_uuid;
204 205
(...skipping 20 matching lines...) Expand all
225 feedback_data->set_attached_file_uuid(attached_file_uuid); 226 feedback_data->set_attached_file_uuid(attached_file_uuid);
226 } 227 }
227 228
228 if (!screenshot_uuid.empty()) 229 if (!screenshot_uuid.empty())
229 feedback_data->set_screenshot_uuid(screenshot_uuid); 230 feedback_data->set_screenshot_uuid(screenshot_uuid);
230 231
231 if (feedback_info.trace_id.get()) { 232 if (feedback_info.trace_id.get()) {
232 feedback_data->set_trace_id(*feedback_info.trace_id.get()); 233 feedback_data->set_trace_id(*feedback_info.trace_id.get());
233 } 234 }
234 235
235 scoped_ptr<FeedbackData::SystemLogsMap> sys_logs( 236 std::unique_ptr<FeedbackData::SystemLogsMap> sys_logs(
236 new FeedbackData::SystemLogsMap); 237 new FeedbackData::SystemLogsMap);
237 SystemInformationList* sys_info = feedback_info.system_information.get(); 238 SystemInformationList* sys_info = feedback_info.system_information.get();
238 if (sys_info) { 239 if (sys_info) {
239 for (const SystemInformation& info : *sys_info) 240 for (const SystemInformation& info : *sys_info)
240 (*sys_logs)[info.key] = info.value; 241 (*sys_logs)[info.key] = info.value;
241 } 242 }
242 feedback_data->SetAndCompressSystemInfo(std::move(sys_logs)); 243 feedback_data->SetAndCompressSystemInfo(std::move(sys_logs));
243 244
244 FeedbackService* service = 245 FeedbackService* service =
245 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); 246 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService();
246 DCHECK(service); 247 DCHECK(service);
247 248
248 if (feedback_info.send_histograms) { 249 if (feedback_info.send_histograms) {
249 scoped_ptr<std::string> histograms(new std::string); 250 std::unique_ptr<std::string> histograms(new std::string);
250 *histograms = base::StatisticsRecorder::ToJSON(std::string()); 251 *histograms = base::StatisticsRecorder::ToJSON(std::string());
251 if (!histograms->empty()) 252 if (!histograms->empty())
252 feedback_data->SetAndCompressHistograms(std::move(histograms)); 253 feedback_data->SetAndCompressHistograms(std::move(histograms));
253 } 254 }
254 255
255 service->SendFeedback( 256 service->SendFeedback(
256 GetProfile(), 257 GetProfile(),
257 feedback_data, 258 feedback_data,
258 base::Bind(&FeedbackPrivateSendFeedbackFunction::OnCompleted, this)); 259 base::Bind(&FeedbackPrivateSendFeedbackFunction::OnCompleted, this));
259 260
260 return true; 261 return true;
261 } 262 }
262 263
263 void FeedbackPrivateSendFeedbackFunction::OnCompleted( 264 void FeedbackPrivateSendFeedbackFunction::OnCompleted(
264 bool success) { 265 bool success) {
265 results_ = feedback_private::SendFeedback::Results::Create( 266 results_ = feedback_private::SendFeedback::Results::Create(
266 success ? feedback_private::STATUS_SUCCESS : 267 success ? feedback_private::STATUS_SUCCESS :
267 feedback_private::STATUS_DELAYED); 268 feedback_private::STATUS_DELAYED);
268 SendResponse(true); 269 SendResponse(true);
269 } 270 }
270 271
271 } // namespace extensions 272 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698