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. 4 5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_FILE_SYSTEM_INTERNALS_SYNC_FILE_SYSTEM_INTERNALS_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SYNC_FILE_SYSTEM_INTERNALS_SYNC_FILE_SYSTEM_INTERNALS_HANDLER_H_ 7 8 #include <string> 9 10 #include "base/compiler_specific.h" 11 #include "base/macros.h" 12 #include "chrome/browser/sync_file_system/sync_event_observer.h" 13 #include "chrome/browser/sync_file_system/task_logger.h" 14 #include "content/public/browser/web_ui_message_handler.h" 15 16 class Profile; 17 18 namespace syncfs_internals { 19 20 // This class handles message from WebUI page of chrome://syncfs-internals/ 21 // for the Sync Service tab. It corresponds to browser/resources/ 22 // sync_file_system_internals/sync_service.html. All methods in this class 23 // should be called on UI thread. 24 class SyncFileSystemInternalsHandler 25 : public content::WebUIMessageHandler, 26 public sync_file_system::SyncEventObserver, 27 public sync_file_system::TaskLogger::Observer { 28 public: 29 explicit SyncFileSystemInternalsHandler(Profile* profile); 30 ~SyncFileSystemInternalsHandler() override; 31 32 // content::WebUIMessageHandler implementation. 33 void RegisterMessages() override; 34 35 // sync_file_system::SyncEventObserver interface implementation. 36 void OnSyncStateUpdated(const GURL& app_origin, 37 sync_file_system::SyncServiceState state, 38 const std::string& description) override; 39 void OnFileSynced(const storage::FileSystemURL& url, 40 sync_file_system::SyncFileType file_type, 41 sync_file_system::SyncFileStatus status, 42 sync_file_system::SyncAction action, 43 sync_file_system::SyncDirection direction) override; 44 45 // sync_file_system::TaskLogger::Observer implementation. 46 void OnLogRecorded( 47 const sync_file_system::TaskLogger::TaskLog& task_log) override; 48 49 private: 50 void GetServiceStatus(const base::ListValue* args); 51 void GetNotificationSource(const base::ListValue* args); 52 void GetLog(const base::ListValue* args); 53 void ClearLogs(const base::ListValue* args); 54 void ObserveTaskLog(const base::ListValue* args); 55 56 Profile* profile_; 57 bool observing_task_log_; 58 59 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemInternalsHandler); 60 }; 61 62 } // namespace syncfs_internals 63 64 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_FILE_SYSTEM_INTERNALS_SYNC_FILE_SYSTEM_INTERNALS_HANDLER_H_ 65