Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / sync_file_system_internals / sync_file_system_internals_handler.h
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   ~SyncFileSystemInternalsHandler() override;
30
31   // content::WebUIMessageHandler implementation.
32   void RegisterMessages() override;
33
34   // sync_file_system::SyncEventObserver interface implementation.
35   void OnSyncStateUpdated(const GURL& app_origin,
36                           sync_file_system::SyncServiceState state,
37                           const std::string& description) override;
38   void OnFileSynced(const storage::FileSystemURL& url,
39                     sync_file_system::SyncFileType file_type,
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   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_