Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync/internal_api/sync_manager.h" | 5 #include "chrome/browser/sync/internal_api/sync_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 &SyncManager::SyncInternal::GetNodeSummariesById); | 163 &SyncManager::SyncInternal::GetNodeSummariesById); |
| 164 BindJsMessageHandler( | 164 BindJsMessageHandler( |
| 165 "getNodeDetailsById", | 165 "getNodeDetailsById", |
| 166 &SyncManager::SyncInternal::GetNodeDetailsById); | 166 &SyncManager::SyncInternal::GetNodeDetailsById); |
| 167 BindJsMessageHandler( | 167 BindJsMessageHandler( |
| 168 "getChildNodeIds", | 168 "getChildNodeIds", |
| 169 &SyncManager::SyncInternal::GetChildNodeIds); | 169 &SyncManager::SyncInternal::GetChildNodeIds); |
| 170 BindJsMessageHandler( | 170 BindJsMessageHandler( |
| 171 "findNodesContainingString", | 171 "findNodesContainingString", |
| 172 &SyncManager::SyncInternal::FindNodesContainingString); | 172 &SyncManager::SyncInternal::FindNodesContainingString); |
| 173 BindJsMessageHandler( | |
| 174 "getClientServerTraffic", | |
| 175 &SyncManager::SyncInternal::GetClientServerTraffic); | |
| 173 } | 176 } |
| 174 | 177 |
| 175 virtual ~SyncInternal() { | 178 virtual ~SyncInternal() { |
| 176 CHECK(!initialized_); | 179 CHECK(!initialized_); |
| 177 } | 180 } |
| 178 | 181 |
| 179 bool Init(const FilePath& database_location, | 182 bool Init(const FilePath& database_location, |
| 180 const WeakHandle<JsEventHandler>& event_handler, | 183 const WeakHandle<JsEventHandler>& event_handler, |
| 181 const std::string& sync_server_and_path, | 184 const std::string& sync_server_and_path, |
| 182 int port, | 185 int port, |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 const NotificationInfoMap& notification_info); | 510 const NotificationInfoMap& notification_info); |
| 508 | 511 |
| 509 // JS message handlers. | 512 // JS message handlers. |
| 510 JsArgList GetNotificationState(const JsArgList& args); | 513 JsArgList GetNotificationState(const JsArgList& args); |
| 511 JsArgList GetNotificationInfo(const JsArgList& args); | 514 JsArgList GetNotificationInfo(const JsArgList& args); |
| 512 JsArgList GetRootNodeDetails(const JsArgList& args); | 515 JsArgList GetRootNodeDetails(const JsArgList& args); |
| 513 JsArgList GetNodeSummariesById(const JsArgList& args); | 516 JsArgList GetNodeSummariesById(const JsArgList& args); |
| 514 JsArgList GetNodeDetailsById(const JsArgList& args); | 517 JsArgList GetNodeDetailsById(const JsArgList& args); |
| 515 JsArgList GetChildNodeIds(const JsArgList& args); | 518 JsArgList GetChildNodeIds(const JsArgList& args); |
| 516 JsArgList FindNodesContainingString(const JsArgList& args); | 519 JsArgList FindNodesContainingString(const JsArgList& args); |
| 520 JsArgList GetClientServerTraffic(const JsArgList& args); | |
| 517 | 521 |
| 518 FilePath database_path_; | 522 FilePath database_path_; |
| 519 | 523 |
| 520 const std::string name_; | 524 const std::string name_; |
| 521 | 525 |
| 522 base::ThreadChecker thread_checker_; | 526 base::ThreadChecker thread_checker_; |
| 523 | 527 |
| 524 base::WeakPtrFactory<SyncInternal> weak_ptr_factory_; | 528 base::WeakPtrFactory<SyncInternal> weak_ptr_factory_; |
| 525 | 529 |
| 526 // Thread-safe handle used by | 530 // Thread-safe handle used by |
| (...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2175 JsArgList SyncManager::SyncInternal::GetRootNodeDetails( | 2179 JsArgList SyncManager::SyncInternal::GetRootNodeDetails( |
| 2176 const JsArgList& args) { | 2180 const JsArgList& args) { |
| 2177 ReadTransaction trans(FROM_HERE, GetUserShare()); | 2181 ReadTransaction trans(FROM_HERE, GetUserShare()); |
| 2178 ReadNode root(&trans); | 2182 ReadNode root(&trans); |
| 2179 root.InitByRootLookup(); | 2183 root.InitByRootLookup(); |
| 2180 ListValue return_args; | 2184 ListValue return_args; |
| 2181 return_args.Append(root.GetDetailsAsValue()); | 2185 return_args.Append(root.GetDetailsAsValue()); |
| 2182 return JsArgList(&return_args); | 2186 return JsArgList(&return_args); |
| 2183 } | 2187 } |
| 2184 | 2188 |
| 2189 JsArgList SyncManager::SyncInternal::GetClientServerTraffic( | |
| 2190 const JsArgList& args) { | |
| 2191 ListValue return_args; | |
| 2192 if (scheduler()) { | |
| 2193 SyncSessionContext* context = scheduler()->session_context(); | |
|
tim (not reviewing)
2012/03/29 22:00:10
It's circuitous and somewhat of a layering violati
rlarocque
2012/03/29 22:54:27
+1
lipalani1
2012/03/29 23:58:37
Done.
lipalani1
2012/03/29 23:58:37
Done.
| |
| 2194 DictionaryValue* value = NULL; | |
| 2195 if (context) | |
| 2196 value = context->traffic_recorder()->ToValue(); | |
| 2197 | |
| 2198 if (value != NULL) | |
| 2199 return_args.Append(value); | |
| 2200 } | |
| 2201 return JsArgList(&return_args); | |
| 2202 } | |
| 2203 | |
| 2185 namespace { | 2204 namespace { |
| 2186 | 2205 |
| 2187 int64 GetId(const ListValue& ids, int i) { | 2206 int64 GetId(const ListValue& ids, int i) { |
| 2188 std::string id_str; | 2207 std::string id_str; |
| 2189 if (!ids.GetString(i, &id_str)) { | 2208 if (!ids.GetString(i, &id_str)) { |
| 2190 return kInvalidId; | 2209 return kInvalidId; |
| 2191 } | 2210 } |
| 2192 int64 id = kInvalidId; | 2211 int64 id = kInvalidId; |
| 2193 if (!base::StringToInt64(id_str, &id)) { | 2212 if (!base::StringToInt64(id_str, &id)) { |
| 2194 return kInvalidId; | 2213 return kInvalidId; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2518 share->directory->GetDownloadProgress(i.Get(), &marker); | 2537 share->directory->GetDownloadProgress(i.Get(), &marker); |
| 2519 | 2538 |
| 2520 if (marker.token().empty()) | 2539 if (marker.token().empty()) |
| 2521 result.Put(i.Get()); | 2540 result.Put(i.Get()); |
| 2522 | 2541 |
| 2523 } | 2542 } |
| 2524 return result; | 2543 return result; |
| 2525 } | 2544 } |
| 2526 | 2545 |
| 2527 } // namespace sync_api | 2546 } // namespace sync_api |
| OLD | NEW |