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_service.h" | 5 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/metrics/statistics_recorder.h" | |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "chrome/browser/chromeos/login/user_manager.h" | 11 #include "chrome/browser/chromeos/login/user_manager.h" |
11 #include "chrome/browser/chromeos/system_logs/scrubbed_system_logs_fetcher.h" | 12 #include "chrome/browser/chromeos/system_logs/scrubbed_system_logs_fetcher.h" |
12 | 13 |
13 using extensions::api::feedback_private::SystemInformation; | 14 using extensions::api::feedback_private::SystemInformation; |
14 | 15 |
15 namespace extensions { | 16 namespace extensions { |
16 | 17 |
17 class FeedbackServiceImpl | 18 class FeedbackServiceImpl |
18 : public FeedbackService, | 19 : public FeedbackService, |
19 public base::SupportsWeakPtr<FeedbackServiceImpl> { | 20 public base::SupportsWeakPtr<FeedbackServiceImpl> { |
20 public: | 21 public: |
21 FeedbackServiceImpl(); | 22 FeedbackServiceImpl(); |
22 virtual ~FeedbackServiceImpl(); | 23 virtual ~FeedbackServiceImpl(); |
23 | 24 |
24 virtual std::string GetUserEmail() OVERRIDE; | 25 virtual std::string GetUserEmail() OVERRIDE; |
25 virtual void GetSystemInformation( | 26 virtual void GetSystemInformation( |
26 const GetSystemInformationCallback& callback) OVERRIDE; | 27 const GetSystemInformationCallback& callback) OVERRIDE; |
28 virtual scoped_ptr<std::string> GetHistograms() OVERRIDE; | |
27 | 29 |
28 private: | 30 private: |
29 void ProcessSystemLogs(scoped_ptr<chromeos::SystemLogsResponse> sys_info); | 31 void ProcessSystemLogs(scoped_ptr<chromeos::SystemLogsResponse> sys_info); |
30 | 32 |
31 // Overridden from FeedbackService: | 33 // Overridden from FeedbackService: |
32 virtual base::WeakPtr<FeedbackService> GetWeakPtr() OVERRIDE; | 34 virtual base::WeakPtr<FeedbackService> GetWeakPtr() OVERRIDE; |
33 | 35 |
34 DISALLOW_COPY_AND_ASSIGN(FeedbackServiceImpl); | 36 DISALLOW_COPY_AND_ASSIGN(FeedbackServiceImpl); |
35 }; | 37 }; |
36 | 38 |
(...skipping 18 matching lines...) Expand all Loading... | |
55 void FeedbackServiceImpl::GetSystemInformation( | 57 void FeedbackServiceImpl::GetSystemInformation( |
56 const GetSystemInformationCallback& callback) { | 58 const GetSystemInformationCallback& callback) { |
57 system_information_callback_ = callback; | 59 system_information_callback_ = callback; |
58 | 60 |
59 chromeos::ScrubbedSystemLogsFetcher* fetcher = | 61 chromeos::ScrubbedSystemLogsFetcher* fetcher = |
60 new chromeos::ScrubbedSystemLogsFetcher(); | 62 new chromeos::ScrubbedSystemLogsFetcher(); |
61 fetcher->Fetch(base::Bind(&FeedbackServiceImpl::ProcessSystemLogs, | 63 fetcher->Fetch(base::Bind(&FeedbackServiceImpl::ProcessSystemLogs, |
62 AsWeakPtr())); | 64 AsWeakPtr())); |
63 } | 65 } |
64 | 66 |
67 scoped_ptr<std::string> FeedbackServiceImpl::GetHistograms() { | |
Alexei Svitkine (slow)
2013/11/02 00:05:26
It's pretty weird as an API to return a scoped_ptr
michaelpg
2013/11/02 17:39:09
Replaced scoped_ptr with out param.
| |
68 scoped_ptr<std::string> json(new std::string); | |
69 base::StatisticsRecorder::WriteJSON(std::string(), json.get()); | |
70 return json.Pass(); | |
71 } | |
72 | |
65 void FeedbackServiceImpl::ProcessSystemLogs( | 73 void FeedbackServiceImpl::ProcessSystemLogs( |
66 scoped_ptr<chromeos::SystemLogsResponse> sys_info_map) { | 74 scoped_ptr<chromeos::SystemLogsResponse> sys_info_map) { |
67 SystemInformationList sys_info_list; | 75 SystemInformationList sys_info_list; |
68 if (!sys_info_map.get()) { | 76 if (!sys_info_map.get()) { |
69 system_information_callback_.Run(sys_info_list); | 77 system_information_callback_.Run(sys_info_list); |
70 return; | 78 return; |
71 } | 79 } |
72 | 80 |
73 for (chromeos::SystemLogsResponse::iterator it = sys_info_map->begin(); | 81 for (chromeos::SystemLogsResponse::iterator it = sys_info_map->begin(); |
74 it != sys_info_map->end(); ++it) | 82 it != sys_info_map->end(); ++it) |
75 FeedbackService::PopulateSystemInfo(&sys_info_list, it->first, it->second); | 83 FeedbackService::PopulateSystemInfo(&sys_info_list, it->first, it->second); |
76 | 84 |
77 system_information_callback_.Run(sys_info_list); | 85 system_information_callback_.Run(sys_info_list); |
78 } | 86 } |
79 | 87 |
80 base::WeakPtr<FeedbackService> FeedbackServiceImpl::GetWeakPtr() { | 88 base::WeakPtr<FeedbackService> FeedbackServiceImpl::GetWeakPtr() { |
81 return AsWeakPtr(); | 89 return AsWeakPtr(); |
82 } | 90 } |
83 | 91 |
84 } // namespace extensions | 92 } // namespace extensions |
OLD | NEW |