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 // The feedback service provides the ability to gather the various pieces of
27 // data needed to send a feedback report and then send the report once all
28 // the pieces are available.
29 class FeedbackService
: public base::SupportsWeakPtr
<FeedbackService
> {
31 typedef base::Callback
<void(bool)> SendFeedbackCallback
;
32 typedef base::Callback
<void(const SystemInformationList
& sys_info
)>
33 GetSystemInformationCallback
;
36 virtual ~FeedbackService();
38 // Sends a feedback report.
39 void SendFeedback(Profile
* profile
,
40 scoped_refptr
<feedback::FeedbackData
> feedback_data
,
41 const SendFeedbackCallback
& callback
);
43 // Start to gather system information.
44 // The |callback| will be invoked once the query is completed.
45 void GetSystemInformation(const GetSystemInformationCallback
& callback
);
48 // Callbacks to receive blob data.
49 void AttachedFileCallback(scoped_ptr
<std::string
> data
,
50 int64 total_blob_length
);
51 void ScreenshotCallback(scoped_ptr
<std::string
> data
,
52 int64 total_blob_length
);
54 // Checks if we have read all the blobs we need to; signals the feedback
55 // data object once all the requisite data has been populated.
56 void CompleteSendFeedback();
58 void OnSystemLogsFetchComplete(
59 scoped_ptr
<system_logs::SystemLogsResponse
> sys_info
);
61 GetSystemInformationCallback system_information_callback_
;
62 SendFeedbackCallback send_feedback_callback_
;
64 scoped_refptr
<feedback::FeedbackData
> feedback_data_
;
66 DISALLOW_COPY_AND_ASSIGN(FeedbackService
);
69 } // namespace extensions
71 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_