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

Side by Side Diff: chrome/browser/extensions/api/feedback_private/feedback_service.h

Issue 1794513002: Fix sending multiple feedback reports within short durations of each other (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplify a lot Created 4 years, 9 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map>
xiyuan 2016/03/16 16:39:28 nit: no longer in use.
afakhry 2016/03/16 17:51:22 Done.
10 #include <vector> 11 #include <vector>
12
11 #include "base/callback.h" 13 #include "base/callback.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
14 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/extensions/blob_reader.h" 17 #include "chrome/browser/extensions/blob_reader.h"
16 #include "chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h" 18 #include "chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h"
17 #include "chrome/common/extensions/api/feedback_private.h" 19 #include "chrome/common/extensions/api/feedback_private.h"
18 #include "components/feedback/feedback_data.h" 20 #include "components/feedback/feedback_data.h"
19 21
20 class Profile; 22 class Profile;
21 23
22 using extensions::api::feedback_private::SystemInformation; 24 using extensions::api::feedback_private::SystemInformation;
23 25
24 namespace extensions { 26 namespace extensions {
25 27
26 typedef std::vector<linked_ptr<SystemInformation> > SystemInformationList; 28 typedef std::vector<linked_ptr<SystemInformation> > SystemInformationList;
27 29
28 // The feedback service provides the ability to gather the various pieces of 30 // The feedback service provides the ability to gather the various pieces of
29 // data needed to send a feedback report and then send the report once all 31 // data needed to send a feedback report and then send the report once all
30 // the pieces are available. 32 // the pieces are available.
31 class FeedbackService : public base::SupportsWeakPtr<FeedbackService> { 33 class FeedbackService : public base::SupportsWeakPtr<FeedbackService> {
32 public: 34 public:
33 typedef base::Callback<void(bool)> SendFeedbackCallback; 35 using SendFeedbackCallback = base::Callback<void(bool)>;
34 typedef base::Callback<void(const SystemInformationList& sys_info)> 36 using GetSystemInformationCallback =
35 GetSystemInformationCallback; 37 base::Callback<void(const SystemInformationList&)>;
36 38
37 FeedbackService(); 39 FeedbackService();
38 virtual ~FeedbackService(); 40 virtual ~FeedbackService();
39 41
40 // Sends a feedback report. 42 // Sends a feedback report.
41 void SendFeedback(Profile* profile, 43 void SendFeedback(Profile* profile,
42 scoped_refptr<feedback::FeedbackData> feedback_data, 44 scoped_refptr<feedback::FeedbackData> feedback_data,
43 const SendFeedbackCallback& callback); 45 const SendFeedbackCallback& callback);
44 46
45 // Start to gather system information. 47 // Start to gather system information.
46 // The |callback| will be invoked once the query is completed. 48 // The |callback| will be invoked once the query is completed.
47 void GetSystemInformation(const GetSystemInformationCallback& callback); 49 void GetSystemInformation(const GetSystemInformationCallback& callback);
48 50
49 private: 51 private:
50 // Callbacks to receive blob data. 52 // Callbacks to receive blob data.
51 void AttachedFileCallback(scoped_ptr<std::string> data, 53 void AttachedFileCallback(scoped_refptr<feedback::FeedbackData> feedback_data,
54 const SendFeedbackCallback& callback,
55 scoped_ptr<std::string> data,
52 int64_t total_blob_length); 56 int64_t total_blob_length);
53 void ScreenshotCallback(scoped_ptr<std::string> data, 57 void ScreenshotCallback(scoped_refptr<feedback::FeedbackData> feedback_data,
58 const SendFeedbackCallback& callback,
59 scoped_ptr<std::string> data,
54 int64_t total_blob_length); 60 int64_t total_blob_length);
55 61
62 void OnSystemLogsFetchComplete(
63 const GetSystemInformationCallback& callback,
64 scoped_ptr<system_logs::SystemLogsResponse> sys_info);
65
56 // Checks if we have read all the blobs we need to; signals the feedback 66 // Checks if we have read all the blobs we need to; signals the feedback
57 // data object once all the requisite data has been populated. 67 // data object once all the requisite data has been populated.
58 void CompleteSendFeedback(); 68 void CompleteSendFeedback(scoped_refptr<feedback::FeedbackData> feedback_data,
59 69 const SendFeedbackCallback& callback);
60 void OnSystemLogsFetchComplete(
61 scoped_ptr<system_logs::SystemLogsResponse> sys_info);
62
63 GetSystemInformationCallback system_information_callback_;
64 SendFeedbackCallback send_feedback_callback_;
65
66 scoped_refptr<feedback::FeedbackData> feedback_data_;
67 70
68 DISALLOW_COPY_AND_ASSIGN(FeedbackService); 71 DISALLOW_COPY_AND_ASSIGN(FeedbackService);
69 }; 72 };
70 73
71 } // namespace extensions 74 } // namespace extensions
72 75
73 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_ 76 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698