Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1097)

Side by Side Diff: sync/internal_api/sync_manager.cc

Issue 10454105: sync: Refactor per-datatype throttling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor fixes Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "sync/internal_api/sync_manager.h" 5 #include "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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "net/base/network_change_notifier.h" 20 #include "net/base/network_change_notifier.h"
21 #include "sync/engine/net/server_connection_manager.h" 21 #include "sync/engine/net/server_connection_manager.h"
22 #include "sync/engine/nigori_util.h" 22 #include "sync/engine/nigori_util.h"
23 #include "sync/engine/sync_scheduler.h" 23 #include "sync/engine/sync_scheduler.h"
24 #include "sync/engine/syncer_types.h" 24 #include "sync/engine/syncer_types.h"
25 #include "sync/engine/throttled_data_type_tracker.h"
25 #include "sync/internal_api/all_status.h" 26 #include "sync/internal_api/all_status.h"
26 #include "sync/internal_api/base_node.h" 27 #include "sync/internal_api/base_node.h"
27 #include "sync/internal_api/change_reorder_buffer.h" 28 #include "sync/internal_api/change_reorder_buffer.h"
28 #include "sync/internal_api/configure_reason.h" 29 #include "sync/internal_api/configure_reason.h"
29 #include "sync/internal_api/debug_info_event_listener.h" 30 #include "sync/internal_api/debug_info_event_listener.h"
30 #include "sync/internal_api/js_mutation_event_observer.h" 31 #include "sync/internal_api/js_mutation_event_observer.h"
31 #include "sync/internal_api/js_sync_manager_observer.h" 32 #include "sync/internal_api/js_sync_manager_observer.h"
32 #include "sync/internal_api/public/engine/polling_constants.h" 33 #include "sync/internal_api/public/engine/polling_constants.h"
33 #include "sync/internal_api/public/syncable/model_type.h" 34 #include "sync/internal_api/public/syncable/model_type.h"
34 #include "sync/internal_api/public/syncable/model_type_payload_map.h" 35 #include "sync/internal_api/public/syncable/model_type_payload_map.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 public ServerConnectionEventListener, 138 public ServerConnectionEventListener,
138 public syncable::DirectoryChangeDelegate { 139 public syncable::DirectoryChangeDelegate {
139 public: 140 public:
140 explicit SyncInternal(const std::string& name) 141 explicit SyncInternal(const std::string& name)
141 : name_(name), 142 : name_(name),
142 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 143 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
143 change_delegate_(NULL), 144 change_delegate_(NULL),
144 initialized_(false), 145 initialized_(false),
145 testing_mode_(NON_TEST), 146 testing_mode_(NON_TEST),
146 observing_ip_address_changes_(false), 147 observing_ip_address_changes_(false),
148 throttled_data_type_tracker_(&allstatus_),
147 traffic_recorder_(kMaxMessagesToRecord, kMaxMessageSizeToRecord), 149 traffic_recorder_(kMaxMessagesToRecord, kMaxMessageSizeToRecord),
148 encryptor_(NULL), 150 encryptor_(NULL),
149 unrecoverable_error_handler_(NULL), 151 unrecoverable_error_handler_(NULL),
150 report_unrecoverable_error_function_(NULL), 152 report_unrecoverable_error_function_(NULL),
151 created_on_loop_(MessageLoop::current()), 153 created_on_loop_(MessageLoop::current()),
152 nigori_overwrite_count_(0) { 154 nigori_overwrite_count_(0) {
153 // Pre-fill |notification_info_map_|. 155 // Pre-fill |notification_info_map_|.
154 for (int i = syncable::FIRST_REAL_MODEL_TYPE; 156 for (int i = syncable::FIRST_REAL_MODEL_TYPE;
155 i < syncable::MODEL_TYPE_COUNT; ++i) { 157 i < syncable::MODEL_TYPE_COUNT; ++i) {
156 notification_info_map_.insert( 158 notification_info_map_.insert(
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // Map used to store the notification info to be displayed in 597 // Map used to store the notification info to be displayed in
596 // about:sync page. 598 // about:sync page.
597 NotificationInfoMap notification_info_map_; 599 NotificationInfoMap notification_info_map_;
598 600
599 // These are for interacting with chrome://sync-internals. 601 // These are for interacting with chrome://sync-internals.
600 JsMessageHandlerMap js_message_handlers_; 602 JsMessageHandlerMap js_message_handlers_;
601 WeakHandle<JsEventHandler> js_event_handler_; 603 WeakHandle<JsEventHandler> js_event_handler_;
602 JsSyncManagerObserver js_sync_manager_observer_; 604 JsSyncManagerObserver js_sync_manager_observer_;
603 JsMutationEventObserver js_mutation_event_observer_; 605 JsMutationEventObserver js_mutation_event_observer_;
604 606
607 browser_sync::ThrottledDataTypeTracker throttled_data_type_tracker_;
608
605 // This is for keeping track of client events to send to the server. 609 // This is for keeping track of client events to send to the server.
606 DebugInfoEventListener debug_info_event_listener_; 610 DebugInfoEventListener debug_info_event_listener_;
607 611
608 browser_sync::TrafficRecorder traffic_recorder_; 612 browser_sync::TrafficRecorder traffic_recorder_;
609 613
610 Encryptor* encryptor_; 614 Encryptor* encryptor_;
611 UnrecoverableErrorHandler* unrecoverable_error_handler_; 615 UnrecoverableErrorHandler* unrecoverable_error_handler_;
612 ReportUnrecoverableErrorFunction report_unrecoverable_error_function_; 616 ReportUnrecoverableErrorFunction report_unrecoverable_error_function_;
613 617
614 MessageLoop* const created_on_loop_; 618 MessageLoop* const created_on_loop_;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 DVLOG(1) << "Sync is bringing up SyncSessionContext."; 952 DVLOG(1) << "Sync is bringing up SyncSessionContext.";
949 std::vector<SyncEngineEventListener*> listeners; 953 std::vector<SyncEngineEventListener*> listeners;
950 listeners.push_back(&allstatus_); 954 listeners.push_back(&allstatus_);
951 listeners.push_back(this); 955 listeners.push_back(this);
952 session_context_.reset(new SyncSessionContext( 956 session_context_.reset(new SyncSessionContext(
953 connection_manager_.get(), 957 connection_manager_.get(),
954 directory(), 958 directory(),
955 model_safe_routing_info, 959 model_safe_routing_info,
956 workers, 960 workers,
957 extensions_activity_monitor, 961 extensions_activity_monitor,
962 &throttled_data_type_tracker_,
958 listeners, 963 listeners,
959 &debug_info_event_listener_, 964 &debug_info_event_listener_,
960 &traffic_recorder_)); 965 &traffic_recorder_));
961 session_context()->set_account_name(credentials.email); 966 session_context()->set_account_name(credentials.email);
962 scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer())); 967 scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer()));
963 } 968 }
964 969
965 bool signed_in = SignIn(credentials); 970 bool signed_in = SignIn(credentials);
966 971
967 if (signed_in) { 972 if (signed_in) {
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 share->directory->GetDownloadProgress(i.Get(), &marker); 2507 share->directory->GetDownloadProgress(i.Get(), &marker);
2503 2508
2504 if (marker.token().empty()) 2509 if (marker.token().empty())
2505 result.Put(i.Get()); 2510 result.Put(i.Get());
2506 2511
2507 } 2512 }
2508 return result; 2513 return result;
2509 } 2514 }
2510 2515
2511 } // namespace sync_api 2516 } // namespace sync_api
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698