OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_in
ternals_handler.h" | 5 #include "chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_in
ternals_handler.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 sync_file_system::SyncServiceState state, | 79 sync_file_system::SyncServiceState state, |
80 const std::string& description) { | 80 const std::string& description) { |
81 std::string state_string = extensions::api::sync_file_system::ToString( | 81 std::string state_string = extensions::api::sync_file_system::ToString( |
82 extensions::SyncServiceStateToExtensionEnum(state)); | 82 extensions::SyncServiceStateToExtensionEnum(state)); |
83 if (!description.empty()) | 83 if (!description.empty()) |
84 state_string += " (" + description + ")"; | 84 state_string += " (" + description + ")"; |
85 | 85 |
86 // TODO(calvinlo): OnSyncStateUpdated should be updated to also provide the | 86 // TODO(calvinlo): OnSyncStateUpdated should be updated to also provide the |
87 // notification mechanism (XMPP or Polling). | 87 // notification mechanism (XMPP or Polling). |
88 web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetServiceStatus", | 88 web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetServiceStatus", |
89 base::StringValue(state_string)); | 89 base::Value(state_string)); |
90 } | 90 } |
91 | 91 |
92 void SyncFileSystemInternalsHandler::OnFileSynced( | 92 void SyncFileSystemInternalsHandler::OnFileSynced( |
93 const storage::FileSystemURL& url, | 93 const storage::FileSystemURL& url, |
94 sync_file_system::SyncFileType file_type, | 94 sync_file_system::SyncFileType file_type, |
95 sync_file_system::SyncFileStatus status, | 95 sync_file_system::SyncFileStatus status, |
96 sync_file_system::SyncAction action, | 96 sync_file_system::SyncAction action, |
97 sync_file_system::SyncDirection direction) { | 97 sync_file_system::SyncDirection direction) { |
98 } | 98 } |
99 | 99 |
(...skipping 14 matching lines...) Expand all Loading... |
114 void SyncFileSystemInternalsHandler::GetServiceStatus( | 114 void SyncFileSystemInternalsHandler::GetServiceStatus( |
115 const base::ListValue* args) { | 115 const base::ListValue* args) { |
116 SyncServiceState state_enum = sync_file_system::SYNC_SERVICE_DISABLED; | 116 SyncServiceState state_enum = sync_file_system::SYNC_SERVICE_DISABLED; |
117 sync_file_system::SyncFileSystemService* sync_service = | 117 sync_file_system::SyncFileSystemService* sync_service = |
118 SyncFileSystemServiceFactory::GetForProfile(profile_); | 118 SyncFileSystemServiceFactory::GetForProfile(profile_); |
119 if (sync_service) | 119 if (sync_service) |
120 state_enum = sync_service->GetSyncServiceState(); | 120 state_enum = sync_service->GetSyncServiceState(); |
121 const std::string state_string = extensions::api::sync_file_system::ToString( | 121 const std::string state_string = extensions::api::sync_file_system::ToString( |
122 extensions::SyncServiceStateToExtensionEnum(state_enum)); | 122 extensions::SyncServiceStateToExtensionEnum(state_enum)); |
123 web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetServiceStatus", | 123 web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetServiceStatus", |
124 base::StringValue(state_string)); | 124 base::Value(state_string)); |
125 } | 125 } |
126 | 126 |
127 void SyncFileSystemInternalsHandler::GetNotificationSource( | 127 void SyncFileSystemInternalsHandler::GetNotificationSource( |
128 const base::ListValue* args) { | 128 const base::ListValue* args) { |
129 drive::DriveNotificationManager* drive_notification_manager = | 129 drive::DriveNotificationManager* drive_notification_manager = |
130 drive::DriveNotificationManagerFactory::FindForBrowserContext(profile_); | 130 drive::DriveNotificationManagerFactory::FindForBrowserContext(profile_); |
131 if (!drive_notification_manager) | 131 if (!drive_notification_manager) |
132 return; | 132 return; |
133 bool xmpp_enabled = drive_notification_manager->push_notification_enabled(); | 133 bool xmpp_enabled = drive_notification_manager->push_notification_enabled(); |
134 std::string notification_source = xmpp_enabled ? "XMPP" : "Polling"; | 134 std::string notification_source = xmpp_enabled ? "XMPP" : "Polling"; |
135 web_ui()->CallJavascriptFunctionUnsafe( | 135 web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetNotificationSource", |
136 "SyncService.onGetNotificationSource", | 136 base::Value(notification_source)); |
137 base::StringValue(notification_source)); | |
138 } | 137 } |
139 | 138 |
140 void SyncFileSystemInternalsHandler::GetLog( | 139 void SyncFileSystemInternalsHandler::GetLog( |
141 const base::ListValue* args) { | 140 const base::ListValue* args) { |
142 const std::vector<EventLogger::Event> log = | 141 const std::vector<EventLogger::Event> log = |
143 sync_file_system::util::GetLogHistory(); | 142 sync_file_system::util::GetLogHistory(); |
144 | 143 |
145 int last_log_id_sent; | 144 int last_log_id_sent; |
146 if (!args->GetInteger(0, &last_log_id_sent)) | 145 if (!args->GetInteger(0, &last_log_id_sent)) |
147 last_log_id_sent = -1; | 146 last_log_id_sent = -1; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 DCHECK(sync_service->task_logger()); | 185 DCHECK(sync_service->task_logger()); |
187 const sync_file_system::TaskLogger::LogList& log = | 186 const sync_file_system::TaskLogger::LogList& log = |
188 sync_service->task_logger()->GetLog(); | 187 sync_service->task_logger()->GetLog(); |
189 | 188 |
190 for (sync_file_system::TaskLogger::LogList::const_iterator itr = log.begin(); | 189 for (sync_file_system::TaskLogger::LogList::const_iterator itr = log.begin(); |
191 itr != log.end(); ++itr) | 190 itr != log.end(); ++itr) |
192 OnLogRecorded(**itr); | 191 OnLogRecorded(**itr); |
193 } | 192 } |
194 | 193 |
195 } // namespace syncfs_internals | 194 } // namespace syncfs_internals |
OLD | NEW |