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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_
9 #include "base/basictypes.h"
10 #include "base/callback.h"
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/extensions/blob_reader.h"
14 #include "chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h"
15 #include "chrome/common/extensions/api/feedback_private.h"
16 #include "components/feedback/feedback_data.h"
20 using extensions::api::feedback_private::SystemInformation;
22 namespace extensions {
24 typedef std::vector<linked_ptr<SystemInformation> > SystemInformationList;
26 class FeedbackService {
28 typedef base::Callback<void(bool)> SendFeedbackCallback;
29 typedef base::Callback<void(const SystemInformationList& sys_info)>
30 GetSystemInformationCallback;
32 // Creates a platform-specific FeedbackService instance.
33 static FeedbackService* CreateInstance();
35 virtual ~FeedbackService();
37 // Sends a feedback report.
38 void SendFeedback(Profile* profile,
39 scoped_refptr<feedback::FeedbackData> feedback_data,
40 const SendFeedbackCallback& callback);
42 // Start to gather system information.
43 // The |callback| will be invoked once the query is completed.
44 void GetSystemInformation(const GetSystemInformationCallback& callback);
46 // Platform specific methods:
47 // Gets the email address of the logged in user.
48 virtual std::string GetUserEmail() = 0;
50 // Gets the histograms in JSON.
51 virtual void GetHistograms(std::string* histograms) = 0;
56 // Used to get a weak ptr for a derived class instance.
57 virtual base::WeakPtr<FeedbackService> GetWeakPtr() = 0;
59 // Callbacks to receive blob data.
60 void AttachedFileCallback(scoped_ptr<std::string> data,
61 int64 total_blob_length);
62 void ScreenshotCallback(scoped_ptr<std::string> data,
63 int64 total_blob_length);
65 // Checks if we have read all the blobs we need to; signals the feedback
66 // data object once all the requisite data has been populated.
67 void CompleteSendFeedback();
70 void OnSystemLogsFetchComplete(
71 scoped_ptr<system_logs::SystemLogsResponse> sys_info);
73 GetSystemInformationCallback system_information_callback_;
74 SendFeedbackCallback send_feedback_callback_;
76 scoped_refptr<feedback::FeedbackData> feedback_data_;
78 DISALLOW_COPY_AND_ASSIGN(FeedbackService);
81 } // namespace extensions
83 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_