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

Unified Diff: chrome/browser/extensions/api/feedback_private/feedback_private_api.h

Issue 2840103002: Add new API function: feedbackPrivate.readLogSource (Closed)
Patch Set: Addressed comments from Patch Set 4 Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/feedback_private/feedback_private_api.h
diff --git a/chrome/browser/extensions/api/feedback_private/feedback_private_api.h b/chrome/browser/extensions/api/feedback_private/feedback_private_api.h
index 3ff94b9c3f70f5f313d42f5b347febf6d19bc50d..72b3ddf5889135b898bb1a16a838a1107744ba2b 100644
--- a/chrome/browser/extensions/api/feedback_private/feedback_private_api.h
+++ b/chrome/browser/extensions/api/feedback_private/feedback_private_api.h
@@ -12,6 +12,12 @@
#include "extensions/browser/extension_function.h"
#include "ui/gfx/geometry/rect.h"
+#if defined(OS_CHROMEOS)
+#include "base/time/time.h"
+#include "chrome/browser/extensions/api/feedback_private/log_source_access_manager.h"
+#include "chrome/browser/extensions/api/feedback_private/log_source_resource.h"
+#endif // defined(OS_CHROMEOS)
+
namespace extensions {
class FeedbackService;
@@ -23,6 +29,12 @@ class FeedbackPrivateAPI : public BrowserContextKeyedAPI {
FeedbackService* GetService() const;
+#if defined(OS_CHROMEOS)
+ LogSourceAccessManager* GetLogSourceAccessManager() {
tbarzic 2017/05/25 22:46:45 for simple getters/setters this would be preferred
Simon Que 2017/05/26 04:34:38 Done.
+ return access_manager_;
+ }
+#endif // defined(OS_CHROMEOS)
+
void RequestFeedback(const std::string& description_template,
const std::string& category_tag,
const GURL& page_url);
@@ -48,6 +60,10 @@ class FeedbackPrivateAPI : public BrowserContextKeyedAPI {
content::BrowserContext* const browser_context_;
FeedbackService* service_;
+
+#if defined(OS_CHROMEOS)
+ LogSourceAccessManager* access_manager_;
+#endif // defined(OS_CHROMEOS)
};
// Feedback strings.
@@ -95,6 +111,52 @@ class FeedbackPrivateGetSystemInformationFunction
void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info);
};
+// This function only reads from actual log sources on Chrome OS. On other
+// platforms, it just returns EmptyResponse().
+class FeedbackPrivateReadLogSourceFunction : public UIThreadExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("feedbackPrivate.readLogSource",
+ FEEDBACKPRIVATE_READLOGSOURCE);
+
+#if defined(OS_CHROMEOS)
+ // To override the default rate-limiting mechanism of this function, pass in
+ // a TimeDelta representing the desired minimum time between consecutive reads
+ // of a source from an extension. Does not take ownership of |timeout|. When
+ // done testing, call this function again with |timeout|=nullptr to reset to
+ // the default behavior.
+ static void SetRateLimitingTimeoutForTesting(const base::TimeDelta* timeout);
+#endif // defined(OS_CHROMEOS)
+
+ protected:
+ ~FeedbackPrivateReadLogSourceFunction() override {}
+ ResponseAction Run() override;
+
+#if defined(OS_CHROMEOS)
+ private:
+ // Looks for an existing LogSourceResource in the API Resource Manager with
+ // id=|reader_id|.
+ // - If the resource exists and was created by the same extension, returns the
+ // resource.
+ // - If the resource exists and was created by a different extension, returns
+ // nullptr.
+ // - If the resource does not exist and there is no existing resource with
+ // source=|source| for the current extension, creates one, stores it in the
+ // API Resource Manager, and returns it.
+ // - If the resource does not exist and there is already an existing resource
+ // source=|source| for the current extension, returns nullptr.
+ //
+ // All returned pointers are owned by the API Resource Manager.
+ LogSourceResource* GetOrCreateLogSourceResource(
+ int reader_id,
+ api::feedback_private::LogSource source);
+
+ void OnCompleted(api::feedback_private::LogSource source,
+ int readerId,
+ bool incremental,
+ system_logs::SystemLogsResponse* response);
+#endif // defined(OS_CHROMEOS)
+};
+
class FeedbackPrivateSendFeedbackFunction
: public ChromeAsyncExtensionFunction {
public:

Powered by Google App Engine
This is Rietveld 408576698