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

Side by Side Diff: chrome/browser/sync/engine/syncapi.cc

Issue 6794005: Move sync notifier contruction out of syncer thread. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase Created 9 years, 8 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
« no previous file with comments | « chrome/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/engine/syncapi_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/engine/syncapi.h" 5 #include "chrome/browser/sync/engine/syncapi.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <bitset> 8 #include <bitset>
9 #include <iomanip> 9 #include <iomanip>
10 #include <list> 10 #include <list>
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 browser_sync::JsEventRouter* parent_router_; 1477 browser_sync::JsEventRouter* parent_router_;
1478 1478
1479 // The ServerConnectionManager used to abstract communication between the 1479 // The ServerConnectionManager used to abstract communication between the
1480 // client (the Syncer) and the sync server. 1480 // client (the Syncer) and the sync server.
1481 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; 1481 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_;
1482 1482
1483 // The thread that runs the Syncer. Needs to be explicitly Start()ed. 1483 // The thread that runs the Syncer. Needs to be explicitly Start()ed.
1484 scoped_ptr<SyncerThreadAdapter> syncer_thread_; 1484 scoped_ptr<SyncerThreadAdapter> syncer_thread_;
1485 1485
1486 // The SyncNotifier which notifies us when updates need to be downloaded. 1486 // The SyncNotifier which notifies us when updates need to be downloaded.
1487 scoped_ptr<sync_notifier::SyncNotifier> sync_notifier_; 1487 sync_notifier::SyncNotifier* sync_notifier_;
1488 1488
1489 // A multi-purpose status watch object that aggregates stats from various 1489 // A multi-purpose status watch object that aggregates stats from various
1490 // sync components. 1490 // sync components.
1491 AllStatus allstatus_; 1491 AllStatus allstatus_;
1492 1492
1493 // Each element of this array is a store of change records produced by 1493 // Each element of this array is a store of change records produced by
1494 // HandleChangeEvent during the CALCULATE_CHANGES step. The changes are 1494 // HandleChangeEvent during the CALCULATE_CHANGES step. The changes are
1495 // segregated by model type, and are stored here to be processed and 1495 // segregated by model type, and are stored here to be processed and
1496 // forwarded to the observer slightly later, at the TRANSACTION_ENDING 1496 // forwarded to the observer slightly later, at the TRANSACTION_ENDING
1497 // step by HandleTransactionEndingChangeEvent. The list is cleared in the 1497 // step by HandleTransactionEndingChangeEvent. The list is cleared in the
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 const std::string& restored_key_for_bootstrapping, 1682 const std::string& restored_key_for_bootstrapping,
1683 bool setup_for_test_mode) { 1683 bool setup_for_test_mode) {
1684 1684
1685 VLOG(1) << "Starting SyncInternal initialization."; 1685 VLOG(1) << "Starting SyncInternal initialization.";
1686 1686
1687 core_message_loop_ = MessageLoop::current(); 1687 core_message_loop_ = MessageLoop::current();
1688 DCHECK(core_message_loop_); 1688 DCHECK(core_message_loop_);
1689 registrar_ = model_safe_worker_registrar; 1689 registrar_ = model_safe_worker_registrar;
1690 setup_for_test_mode_ = setup_for_test_mode; 1690 setup_for_test_mode_ = setup_for_test_mode;
1691 1691
1692 sync_notifier_.reset(sync_notifier); 1692 sync_notifier_ = sync_notifier;
1693 sync_notifier_->AddObserver(this); 1693 sync_notifier_->AddObserver(this);
1694 1694
1695 share_.dir_manager.reset(new DirectoryManager(database_location)); 1695 share_.dir_manager.reset(new DirectoryManager(database_location));
1696 1696
1697 connection_manager_.reset(new SyncAPIServerConnectionManager( 1697 connection_manager_.reset(new SyncAPIServerConnectionManager(
1698 sync_server_and_path, port, use_ssl, user_agent, post_factory)); 1698 sync_server_and_path, port, use_ssl, user_agent, post_factory));
1699 1699
1700 net::NetworkChangeNotifier::AddIPAddressObserver(this); 1700 net::NetworkChangeNotifier::AddIPAddressObserver(this);
1701 1701
1702 bool new_syncer_thread = CommandLine::ForCurrentProcess()->HasSwitch( 1702 bool new_syncer_thread = CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 initialized_ = true; 1805 initialized_ = true;
1806 } 1806 }
1807 1807
1808 // Notify that initialization is complete. 1808 // Notify that initialization is complete.
1809 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, 1809 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
1810 OnInitializationComplete()); 1810 OnInitializationComplete());
1811 } 1811 }
1812 1812
1813 void SyncManager::SyncInternal::SendNotification() { 1813 void SyncManager::SyncInternal::SendNotification() {
1814 DCHECK_EQ(MessageLoop::current(), core_message_loop_); 1814 DCHECK_EQ(MessageLoop::current(), core_message_loop_);
1815 if (!sync_notifier_.get()) { 1815 if (!sync_notifier_) {
1816 VLOG(1) << "Not sending notification: sync_notifier_ is NULL"; 1816 VLOG(1) << "Not sending notification: sync_notifier_ is NULL";
1817 return; 1817 return;
1818 } 1818 }
1819 allstatus_.IncrementNotificationsSent(); 1819 allstatus_.IncrementNotificationsSent();
1820 sync_notifier_->SendNotification(); 1820 sync_notifier_->SendNotification();
1821 } 1821 }
1822 1822
1823 bool SyncManager::SyncInternal::OpenDirectory() { 1823 bool SyncManager::SyncInternal::OpenDirectory() {
1824 DCHECK(!initialized()) << "Should only happen once"; 1824 DCHECK(!initialized()) << "Should only happen once";
1825 1825
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 if (syncer_thread()) { 2126 if (syncer_thread()) {
2127 if (!syncer_thread()->Stop(kThreadExitTimeoutMsec)) { 2127 if (!syncer_thread()->Stop(kThreadExitTimeoutMsec)) {
2128 LOG(FATAL) << "Unable to stop the syncer, it won't be happy..."; 2128 LOG(FATAL) << "Unable to stop the syncer, it won't be happy...";
2129 } 2129 }
2130 syncer_thread_.reset(); 2130 syncer_thread_.reset();
2131 } 2131 }
2132 2132
2133 // We NULL out sync_notifer_ so that any pending tasks do not 2133 // We NULL out sync_notifer_ so that any pending tasks do not
2134 // trigger further notifications. 2134 // trigger further notifications.
2135 // TODO(akalin): NULL the other member variables defensively, too. 2135 // TODO(akalin): NULL the other member variables defensively, too.
2136 if (sync_notifier_.get()) { 2136 if (sync_notifier_) {
2137 sync_notifier_->RemoveObserver(this); 2137 sync_notifier_->RemoveObserver(this);
2138 sync_notifier_.reset();
2139 } 2138 }
2140 2139
2141 // Pump any messages the auth watcher, syncer thread, or talk 2140 // Pump any messages the auth watcher, syncer thread, or talk
2142 // mediator posted before they shut down. (See OnSyncEngineEvent(), 2141 // mediator posted before they shut down. (See OnSyncEngineEvent(),
2143 // and HandleTalkMediatorEvent() for the 2142 // and HandleTalkMediatorEvent() for the
2144 // events that may be posted.) 2143 // events that may be posted.)
2145 { 2144 {
2146 CHECK(core_message_loop_); 2145 CHECK(core_message_loop_);
2147 bool old_state = core_message_loop_->NestableTasksAllowed(); 2146 bool old_state = core_message_loop_->NestableTasksAllowed();
2148 core_message_loop_->SetNestableTasksAllowed(true); 2147 core_message_loop_->SetNestableTasksAllowed(true);
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
2768 void SyncManager::TriggerOnIncomingNotificationForTest( 2767 void SyncManager::TriggerOnIncomingNotificationForTest(
2769 const syncable::ModelTypeBitSet& model_types) { 2768 const syncable::ModelTypeBitSet& model_types) {
2770 syncable::ModelTypePayloadMap model_types_with_payloads = 2769 syncable::ModelTypePayloadMap model_types_with_payloads =
2771 syncable::ModelTypePayloadMapFromBitSet(model_types, 2770 syncable::ModelTypePayloadMapFromBitSet(model_types,
2772 std::string()); 2771 std::string());
2773 2772
2774 data_->OnIncomingNotification(model_types_with_payloads); 2773 data_->OnIncomingNotification(model_types_with_payloads);
2775 } 2774 }
2776 2775
2777 } // namespace sync_api 2776 } // namespace sync_api
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/engine/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698