1b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)// found in the LICENSE file. 4b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 5b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_FILE_SYSTEM_INTERNALS_SYNC_FILE_SYSTEM_INTERNALS_HANDLER_H_ 6b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#define CHROME_BROWSER_UI_WEBUI_SYNC_FILE_SYSTEM_INTERNALS_SYNC_FILE_SYSTEM_INTERNALS_HANDLER_H_ 7b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 8cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include <string> 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 10b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#include "base/compiler_specific.h" 115e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)#include "chrome/browser/sync_file_system/sync_event_observer.h" 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/sync_file_system/task_logger.h" 13b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#include "content/public/browser/web_ui_message_handler.h" 14b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 15b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)class Profile; 16b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 17b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)namespace syncfs_internals { 18b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 197d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// This class handles message from WebUI page of chrome://syncfs-internals/ 207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// for the Sync Service tab. It corresponds to browser/resources/ 217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// sync_file_system_internals/sync_service.html. All methods in this class 227d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// should be called on UI thread. 235e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)class SyncFileSystemInternalsHandler 245e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) : public content::WebUIMessageHandler, 25cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) public sync_file_system::SyncEventObserver, 26cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) public sync_file_system::TaskLogger::Observer { 27b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) public: 28b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) explicit SyncFileSystemInternalsHandler(Profile* profile); 29b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) virtual ~SyncFileSystemInternalsHandler(); 305e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) 315e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) // content::WebUIMessageHandler implementation. 32b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) virtual void RegisterMessages() OVERRIDE; 33b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 345e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) // sync_file_system::SyncEventObserver interface implementation. 355e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) virtual void OnSyncStateUpdated( 365e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) const GURL& app_origin, 375e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) sync_file_system::SyncServiceState state, 385e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) const std::string& description) OVERRIDE; 3903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) virtual void OnFileSynced(const storage::FileSystemURL& url, 4003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) sync_file_system::SyncFileStatus status, 4103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) sync_file_system::SyncAction action, 4203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) sync_file_system::SyncDirection direction) OVERRIDE; 435e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) 44cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // sync_file_system::TaskLogger::Observer implementation. 45cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void OnLogRecorded( 46cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const sync_file_system::TaskLogger::TaskLog& task_log) OVERRIDE; 47cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 48b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) private: 49b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) void GetServiceStatus(const base::ListValue* args); 5090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void GetNotificationSource(const base::ListValue* args); 5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void GetLog(const base::ListValue* args); 52a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void ClearLogs(const base::ListValue* args); 53cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) void ObserveTaskLog(const base::ListValue* args); 54b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 55b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) Profile* profile_; 56cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool observing_task_log_; 57b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 58b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(SyncFileSystemInternalsHandler); 59b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)}; 607d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 615e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)} // namespace syncfs_internals 62b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 63b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#endif // CHROME_BROWSER_UI_WEBUI_SYNC_FILE_SYSTEM_INTERNALS_SYNC_FILE_SYSTEM_INTERNALS_HANDLER_H_ 64