| 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 #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 <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/extensions/blob_reader.h" | 15 #include "chrome/browser/extensions/blob_reader.h" |
| 16 #include "chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h" | 16 #include "chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h" |
| 17 #include "chrome/common/extensions/api/feedback_private.h" | |
| 18 #include "components/feedback/feedback_data.h" | 17 #include "components/feedback/feedback_data.h" |
| 19 | 18 |
| 20 class Profile; | 19 class Profile; |
| 21 | 20 |
| 22 namespace extensions { | 21 namespace extensions { |
| 23 | 22 |
| 24 using SystemInformationList = | |
| 25 std::vector<api::feedback_private::SystemInformation>; | |
| 26 | |
| 27 // The feedback service provides the ability to gather the various pieces of | 23 // The feedback service provides the ability to gather the various pieces of |
| 28 // data needed to send a feedback report and then send the report once all | 24 // data needed to send a feedback report and then send the report once all |
| 29 // the pieces are available. | 25 // the pieces are available. |
| 30 class FeedbackService : public base::SupportsWeakPtr<FeedbackService> { | 26 class FeedbackService : public base::SupportsWeakPtr<FeedbackService> { |
| 31 public: | 27 public: |
| 32 // Callback invoked when the feedback report is ready to be sent. | 28 // Callback invoked when the feedback report is ready to be sent. |
| 33 // True will be passed to indicate that it is being successfully sent now, | 29 // True will be passed to indicate that it is being successfully sent now, |
| 34 // and false to indicate that it will be delayed (usually due to being | 30 // and false to indicate that it will be delayed (usually due to being |
| 35 // offline). | 31 // offline). |
| 36 using SendFeedbackCallback = base::Callback<void(bool)>; | 32 using SendFeedbackCallback = base::Callback<void(bool)>; |
| 37 | 33 |
| 38 using GetSystemInformationCallback = | |
| 39 base::Callback<void(const SystemInformationList&)>; | |
| 40 | |
| 41 FeedbackService(); | 34 FeedbackService(); |
| 42 virtual ~FeedbackService(); | 35 virtual ~FeedbackService(); |
| 43 | 36 |
| 44 // Sends a feedback report. | 37 // Sends a feedback report. |
| 45 void SendFeedback(Profile* profile, | 38 void SendFeedback(Profile* profile, |
| 46 scoped_refptr<feedback::FeedbackData> feedback_data, | 39 scoped_refptr<feedback::FeedbackData> feedback_data, |
| 47 const SendFeedbackCallback& callback); | 40 const SendFeedbackCallback& callback); |
| 48 | 41 |
| 49 // Start to gather system information. | 42 // Start to gather system information. |
| 50 // The |callback| will be invoked once the query is completed. | 43 // The |callback| will be invoked once the query is completed. |
| 51 void GetSystemInformation(const GetSystemInformationCallback& callback); | 44 void GetSystemInformation( |
| 45 const system_logs::SysLogsFetcherCallback& callback); |
| 52 | 46 |
| 53 private: | 47 private: |
| 54 // Callbacks to receive blob data. | 48 // Callbacks to receive blob data. |
| 55 void AttachedFileCallback(scoped_refptr<feedback::FeedbackData> feedback_data, | 49 void AttachedFileCallback(scoped_refptr<feedback::FeedbackData> feedback_data, |
| 56 const SendFeedbackCallback& callback, | 50 const SendFeedbackCallback& callback, |
| 57 std::unique_ptr<std::string> data, | 51 std::unique_ptr<std::string> data, |
| 58 int64_t total_blob_length); | 52 int64_t total_blob_length); |
| 59 void ScreenshotCallback(scoped_refptr<feedback::FeedbackData> feedback_data, | 53 void ScreenshotCallback(scoped_refptr<feedback::FeedbackData> feedback_data, |
| 60 const SendFeedbackCallback& callback, | 54 const SendFeedbackCallback& callback, |
| 61 std::unique_ptr<std::string> data, | 55 std::unique_ptr<std::string> data, |
| 62 int64_t total_blob_length); | 56 int64_t total_blob_length); |
| 63 | 57 |
| 64 void OnSystemLogsFetchComplete( | |
| 65 const GetSystemInformationCallback& callback, | |
| 66 std::unique_ptr<system_logs::SystemLogsResponse> sys_info); | |
| 67 | |
| 68 // Checks if we have read all the blobs we need to; signals the feedback | 58 // Checks if we have read all the blobs we need to; signals the feedback |
| 69 // data object once all the requisite data has been populated. | 59 // data object once all the requisite data has been populated. |
| 70 void CompleteSendFeedback(scoped_refptr<feedback::FeedbackData> feedback_data, | 60 void CompleteSendFeedback(scoped_refptr<feedback::FeedbackData> feedback_data, |
| 71 const SendFeedbackCallback& callback); | 61 const SendFeedbackCallback& callback); |
| 72 | 62 |
| 73 DISALLOW_COPY_AND_ASSIGN(FeedbackService); | 63 DISALLOW_COPY_AND_ASSIGN(FeedbackService); |
| 74 }; | 64 }; |
| 75 | 65 |
| 76 } // namespace extensions | 66 } // namespace extensions |
| 77 | 67 |
| 78 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_ | 68 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_ |
| OLD | NEW |