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