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

Unified Diff: chrome/browser/extensions/api/feedback_private/feedback_private_api.cc

Issue 2635473003: Optimize sending sys info to the feedback app (Closed)
Patch Set: Xiyuan's comments Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/feedback_private/feedback_private_api.cc
diff --git a/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc b/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc
index 10fdd04d3fd17bc5e712cedad514f285422830e2..ea22eb4a03756696a1921c450707ede9818dae79 100644
--- a/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc
+++ b/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/simple_message_box.h"
+#include "chrome/common/extensions/api/feedback_private.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/feedback/tracing_manager.h"
@@ -73,6 +74,9 @@ using feedback_private::SystemInformation;
using feedback_private::FeedbackInfo;
using feedback_private::FeedbackFlow;
+using SystemInformationList =
+ std::vector<api::feedback_private::SystemInformation>;
+
static base::LazyInstance<BrowserContextKeyedAPIFactory<FeedbackPrivateAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;
@@ -220,21 +224,33 @@ ExtensionFunction::ResponseAction FeedbackPrivateGetUserEmailFunction::Run() {
: std::string())));
}
-bool FeedbackPrivateGetSystemInformationFunction::RunAsync() {
- FeedbackService* service =
- FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService();
+ExtensionFunction::ResponseAction
+FeedbackPrivateGetSystemInformationFunction::Run() {
+ FeedbackService* service = FeedbackPrivateAPI::GetFactoryInstance()
+ ->Get(browser_context())
+ ->GetService();
DCHECK(service);
service->GetSystemInformation(
base::Bind(
&FeedbackPrivateGetSystemInformationFunction::OnCompleted, this));
- return true;
+ return RespondLater();
}
void FeedbackPrivateGetSystemInformationFunction::OnCompleted(
- const SystemInformationList& sys_info) {
- results_ = feedback_private::GetSystemInformation::Results::Create(
- sys_info);
- SendResponse(true);
+ std::unique_ptr<system_logs::SystemLogsResponse> sys_info) {
+ SystemInformationList sys_info_list;
+ if (sys_info) {
+ sys_info_list.reserve(sys_info->size());
+ for (auto& itr : *sys_info) {
+ SystemInformation sys_info_entry;
+ sys_info_entry.key = std::move(itr.first);
+ sys_info_entry.value = std::move(itr.second);
+ sys_info_list.emplace_back(std::move(sys_info_entry));
+ }
+ }
+
+ Respond(ArgumentList(
+ feedback_private::GetSystemInformation::Results::Create(sys_info_list)));
}
bool FeedbackPrivateSendFeedbackFunction::RunAsync() {

Powered by Google App Engine
This is Rietveld 408576698