OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/sync/engine/syncer_thread.h" | 4 #include "chrome/browser/sync/engine/syncer_thread.h" |
5 | 5 |
6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
7 | 7 |
8 #if defined(OS_MACOSX) | 8 #if defined(OS_MACOSX) |
9 #include <CoreFoundation/CFNumber.h> | 9 #include <CoreFoundation/CFNumber.h> |
10 #include <IOKit/IOTypes.h> | 10 #include <IOKit/IOTypes.h> |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // off the queue and wait for that delta. If it was a spurious signal, | 329 // off the queue and wait for that delta. If it was a spurious signal, |
330 // we'll keep waiting for the same moment in time as we just were. | 330 // we'll keep waiting for the same moment in time as we just were. |
331 continue; | 331 continue; |
332 } | 332 } |
333 } | 333 } |
334 | 334 |
335 // Handle a nudge, caused by either a notification or a local bookmark | 335 // Handle a nudge, caused by either a notification or a local bookmark |
336 // event. This will also update the source of the following SyncMain call. | 336 // event. This will also update the source of the following SyncMain call. |
337 VLOG(1) << "Calling Sync Main at time " << Time::Now().ToInternalValue(); | 337 VLOG(1) << "Calling Sync Main at time " << Time::Now().ToInternalValue(); |
338 bool nudged = false; | 338 bool nudged = false; |
339 scoped_ptr<SyncSession> session; | 339 scoped_refptr<SyncSession> session; |
340 session.reset(SyncMain(vault_.syncer_, | 340 session = SyncMain(vault_.syncer_, |
341 throttled, continue_sync_cycle, &initial_sync_for_thread, &nudged)); | 341 throttled, continue_sync_cycle, &initial_sync_for_thread, &nudged); |
342 | 342 |
343 // Update timing information for how often these datatypes are triggering | 343 // Update timing information for how often these datatypes are triggering |
344 // nudges. | 344 // nudges. |
345 base::TimeTicks now = TimeTicks::Now(); | 345 base::TimeTicks now = TimeTicks::Now(); |
346 for (size_t i = syncable::FIRST_REAL_MODEL_TYPE; | 346 for (size_t i = syncable::FIRST_REAL_MODEL_TYPE; |
347 i < session->source().second.size(); | 347 i < session->source().second.size(); |
348 ++i) { | 348 ++i) { |
349 if (session->source().second[i]) { | 349 if (session->source().second[i]) { |
350 syncable::PostTimeToTypeHistogram(syncable::ModelType(i), | 350 syncable::PostTimeToTypeHistogram(syncable::ModelType(i), |
351 now - last_sync_time); | 351 now - last_sync_time); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // are not currently silenced so reset this state for the next session which | 528 // are not currently silenced so reset this state for the next session which |
529 // may need to use it. | 529 // may need to use it. |
530 silenced_until_ = base::TimeTicks(); | 530 silenced_until_ = base::TimeTicks(); |
531 | 531 |
532 ModelSafeRoutingInfo routes; | 532 ModelSafeRoutingInfo routes; |
533 std::vector<ModelSafeWorker*> workers; | 533 std::vector<ModelSafeWorker*> workers; |
534 session_context_->registrar()->GetModelSafeRoutingInfo(&routes); | 534 session_context_->registrar()->GetModelSafeRoutingInfo(&routes); |
535 session_context_->registrar()->GetWorkers(&workers); | 535 session_context_->registrar()->GetWorkers(&workers); |
536 SyncSourceInfo info(GetAndResetNudgeSource(was_throttled, | 536 SyncSourceInfo info(GetAndResetNudgeSource(was_throttled, |
537 continue_sync_cycle, initial_sync_for_thread, was_nudged)); | 537 continue_sync_cycle, initial_sync_for_thread, was_nudged)); |
538 scoped_ptr<SyncSession> session; | 538 scoped_refptr<SyncSession> session; |
539 | 539 |
540 AutoUnlock unlock(lock_); | 540 AutoUnlock unlock(lock_); |
541 do { | 541 do { |
542 session.reset(new SyncSession(session_context_.get(), this, | 542 session = new SyncSession(session_context_.get(), this, |
543 info, routes, workers)); | 543 info, routes, workers); |
544 VLOG(1) << "Calling SyncShare."; | 544 VLOG(1) << "Calling SyncShare."; |
545 syncer->SyncShare(session.get()); | 545 syncer->SyncShare(session.get()); |
546 } while (session->HasMoreToSync() && silenced_until_.is_null()); | 546 } while (session->HasMoreToSync() && silenced_until_.is_null()); |
547 | 547 |
548 VLOG(1) << "Done calling SyncShare."; | 548 VLOG(1) << "Done calling SyncShare."; |
549 return session.release(); | 549 return session.release(); |
550 } | 550 } |
551 | 551 |
552 SyncSourceInfo SyncerThread::GetAndResetNudgeSource(bool was_throttled, | 552 SyncSourceInfo SyncerThread::GetAndResetNudgeSource(bool was_throttled, |
553 bool continue_sync_cycle, | 553 bool continue_sync_cycle, |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 was_logged = true; | 823 was_logged = true; |
824 VLOG(1) << "UserIdleTime unimplemented on this platform, synchronization " | 824 VLOG(1) << "UserIdleTime unimplemented on this platform, synchronization " |
825 "will not throttle when user idle"; | 825 "will not throttle when user idle"; |
826 } | 826 } |
827 #endif | 827 #endif |
828 | 828 |
829 return 0; | 829 return 0; |
830 } | 830 } |
831 | 831 |
832 } // namespace browser_sync | 832 } // namespace browser_sync |
OLD | NEW |