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

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: 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>
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:
35 typedef int64_t RequestId;
xiyuan 2016/03/14 23:47:28 nit: new style is to use "using" using RequestId
afakhry 2016/03/15 19:25:38 Done.
33 typedef base::Callback<void(bool)> SendFeedbackCallback; 36 typedef base::Callback<void(bool)> SendFeedbackCallback;
34 typedef base::Callback<void(const SystemInformationList& sys_info)> 37 typedef base::Callback<void(const SystemInformationList& sys_info)>
35 GetSystemInformationCallback; 38 GetSystemInformationCallback;
36 39
37 FeedbackService(); 40 FeedbackService();
38 virtual ~FeedbackService(); 41 virtual ~FeedbackService();
39 42
40 // Sends a feedback report. 43 // Sends a feedback report.
41 void SendFeedback(Profile* profile, 44 void SendFeedback(Profile* profile,
42 scoped_refptr<feedback::FeedbackData> feedback_data, 45 scoped_refptr<feedback::FeedbackData> feedback_data,
43 const SendFeedbackCallback& callback); 46 const SendFeedbackCallback& callback);
44 47
45 // Start to gather system information. 48 // Start to gather system information.
46 // The |callback| will be invoked once the query is completed. 49 // The |callback| will be invoked once the query is completed.
47 void GetSystemInformation(const GetSystemInformationCallback& callback); 50 void GetSystemInformation(const GetSystemInformationCallback& callback);
48 51
49 private: 52 private:
53 struct SendRequest;
54
50 // Callbacks to receive blob data. 55 // Callbacks to receive blob data.
51 void AttachedFileCallback(scoped_ptr<std::string> data, 56 void AttachedFileCallback(RequestId request_id,
57 scoped_ptr<std::string> data,
52 int64_t total_blob_length); 58 int64_t total_blob_length);
53 void ScreenshotCallback(scoped_ptr<std::string> data, 59 void ScreenshotCallback(RequestId request_id,
60 scoped_ptr<std::string> data,
54 int64_t total_blob_length); 61 int64_t total_blob_length);
55 62
63 void OnSystemLogsFetchComplete(
64 RequestId request_id,
65 scoped_ptr<system_logs::SystemLogsResponse> sys_info);
66
56 // Checks if we have read all the blobs we need to; signals the feedback 67 // 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. 68 // data object once all the requisite data has been populated.
58 void CompleteSendFeedback(); 69 void CompleteSendFeedback(RequestId request_id);
59 70
60 void OnSystemLogsFetchComplete( 71 std::map<RequestId, GetSystemInformationCallback>
61 scoped_ptr<system_logs::SystemLogsResponse> sys_info); 72 system_information_callbacks_;
62 73
63 GetSystemInformationCallback system_information_callback_; 74 std::map<RequestId, SendRequest> send_feedback_requests_;
64 SendFeedbackCallback send_feedback_callback_;
65
66 scoped_refptr<feedback::FeedbackData> feedback_data_;
67 75
68 DISALLOW_COPY_AND_ASSIGN(FeedbackService); 76 DISALLOW_COPY_AND_ASSIGN(FeedbackService);
69 }; 77 };
70 78
71 } // namespace extensions 79 } // namespace extensions
72 80
73 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_ 81 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698