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/glue/model_association_manager.h" | 5 #include "chrome/browser/sync/glue/model_association_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 if (state_ == CONFIGURING) { | 233 if (state_ == CONFIGURING) { |
| 234 DVLOG(1) << "ModelAssociationManager: In the middle of configuration while" | 234 DVLOG(1) << "ModelAssociationManager: In the middle of configuration while" |
| 235 << " stopping"; | 235 << " stopping"; |
| 236 state_ = ABORTED; | 236 state_ = ABORTED; |
| 237 DCHECK(currently_associating_ != NULL || | 237 DCHECK(currently_associating_ != NULL || |
| 238 needs_start_.size() > 0 || | 238 needs_start_.size() > 0 || |
| 239 pending_model_load_.size() > 0 || | 239 pending_model_load_.size() > 0 || |
| 240 waiting_to_associate_.size() > 0); | 240 waiting_to_associate_.size() > 0); |
| 241 | 241 |
| 242 if (currently_associating_) { | 242 if (currently_associating_) { |
| 243 TRACE_EVENT_END0("sync", "ModelAssociation"); | 243 TRACE_EVENT_ASYNC_END1("sync", "ModelAssociation", |
| 244 "DataType", | |
| 245 ModelTypeToString(currently_associating_->type()), | |
| 246 currently_associating_); | |
| 244 DVLOG(1) << "ModelAssociationManager: stopping " | 247 DVLOG(1) << "ModelAssociationManager: stopping " |
| 245 << currently_associating_->name(); | 248 << currently_associating_->name(); |
| 246 currently_associating_->Stop(); | 249 currently_associating_->Stop(); |
| 247 } else { | 250 } else { |
| 248 // DTCs in other lists would be stopped below. | 251 // DTCs in other lists would be stopped below. |
| 249 state_ = IDLE; | 252 state_ = IDLE; |
| 250 } | 253 } |
| 251 | 254 |
| 252 DCHECK_EQ(IDLE, state_); | 255 DCHECK_EQ(IDLE, state_); |
| 253 | 256 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 UMA_HISTOGRAM_ENUMERATION("Sync.ConfigureFailed", | 320 UMA_HISTOGRAM_ENUMERATION("Sync.ConfigureFailed", |
| 318 ModelTypeToHistogramInt(error.model_type()), | 321 ModelTypeToHistogramInt(error.model_type()), |
| 319 syncer::MODEL_TYPE_COUNT); | 322 syncer::MODEL_TYPE_COUNT); |
| 320 } | 323 } |
| 321 | 324 |
| 322 void ModelAssociationManager::TypeStartCallback( | 325 void ModelAssociationManager::TypeStartCallback( |
| 323 DataTypeController::StartResult start_result, | 326 DataTypeController::StartResult start_result, |
| 324 const syncer::SyncMergeResult& local_merge_result, | 327 const syncer::SyncMergeResult& local_merge_result, |
| 325 const syncer::SyncMergeResult& syncer_merge_result) { | 328 const syncer::SyncMergeResult& syncer_merge_result) { |
| 326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 327 TRACE_EVENT_END0("sync", "ModelAssociation"); | 330 TRACE_EVENT_ASYNC_END1("sync", "ModelAssociation", |
| 331 "DataType", | |
| 332 ModelTypeToString(currently_associating_->type()), | |
| 333 currently_associating_); | |
| 328 | 334 |
| 329 DVLOG(1) << "ModelAssociationManager: TypeStartCallback"; | 335 DVLOG(1) << "ModelAssociationManager: TypeStartCallback"; |
| 330 if (state_ == ABORTED) { | 336 if (state_ == ABORTED) { |
| 331 // Now that we have finished with the current type we can stop | 337 // Now that we have finished with the current type we can stop |
| 332 // if abort was called. | 338 // if abort was called. |
| 333 DVLOG(1) << "ModelAssociationManager: Doing an early return" | 339 DVLOG(1) << "ModelAssociationManager: Doing an early return" |
| 334 << " because of abort"; | 340 << " because of abort"; |
| 335 state_ = IDLE; | 341 state_ = IDLE; |
| 336 return; | 342 return; |
| 337 } | 343 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 } | 512 } |
| 507 | 513 |
| 508 void ModelAssociationManager::StartAssociatingNextType() { | 514 void ModelAssociationManager::StartAssociatingNextType() { |
| 509 DCHECK_EQ(state_, CONFIGURING); | 515 DCHECK_EQ(state_, CONFIGURING); |
| 510 DCHECK_EQ(currently_associating_, static_cast<DataTypeController*>(NULL)); | 516 DCHECK_EQ(currently_associating_, static_cast<DataTypeController*>(NULL)); |
| 511 | 517 |
| 512 DVLOG(1) << "ModelAssociationManager: StartAssociatingNextType"; | 518 DVLOG(1) << "ModelAssociationManager: StartAssociatingNextType"; |
| 513 if (!waiting_to_associate_.empty()) { | 519 if (!waiting_to_associate_.empty()) { |
| 514 DVLOG(1) << "ModelAssociationManager: Starting " | 520 DVLOG(1) << "ModelAssociationManager: Starting " |
| 515 << waiting_to_associate_[0]->name(); | 521 << waiting_to_associate_[0]->name(); |
| 516 TRACE_EVENT_BEGIN1("sync", "ModelAssociation", | |
| 517 "DataType", | |
| 518 ModelTypeToString(waiting_to_associate_[0]->type())); | |
| 519 DataTypeController* dtc = waiting_to_associate_[0]; | 522 DataTypeController* dtc = waiting_to_associate_[0]; |
| 520 waiting_to_associate_.erase(waiting_to_associate_.begin()); | 523 waiting_to_associate_.erase(waiting_to_associate_.begin()); |
| 521 currently_associating_ = dtc; | 524 currently_associating_ = dtc; |
| 522 current_type_association_start_time_ = base::Time::Now(); | 525 current_type_association_start_time_ = base::Time::Now(); |
| 526 TRACE_EVENT_ASYNC_BEGIN1("sync", "ModelAssociation", | |
| 527 "DataType", | |
| 528 ModelTypeToString(currently_associating_->type()), | |
| 529 currently_associating_); | |
|
Raghu Simha
2013/09/07 00:20:18
I think the order of arguments in these calls is i
| |
| 523 dtc->StartAssociating(base::Bind( | 530 dtc->StartAssociating(base::Bind( |
| 524 &ModelAssociationManager::TypeStartCallback, | 531 &ModelAssociationManager::TypeStartCallback, |
| 525 weak_ptr_factory_.GetWeakPtr())); | 532 weak_ptr_factory_.GetWeakPtr())); |
| 526 return; | 533 return; |
| 527 } | 534 } |
| 528 | 535 |
| 529 // We are done with this cycle of association. Stop any failed types now. | 536 // We are done with this cycle of association. Stop any failed types now. |
| 530 needs_stop_.clear(); | 537 needs_stop_.clear(); |
| 531 for (DataTypeController::TypeMap::const_iterator it = controllers_->begin(); | 538 for (DataTypeController::TypeMap::const_iterator it = controllers_->begin(); |
| 532 it != controllers_->end(); ++it) { | 539 it != controllers_->end(); ++it) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 } | 579 } |
| 573 return result; | 580 return result; |
| 574 } | 581 } |
| 575 | 582 |
| 576 base::OneShotTimer<ModelAssociationManager>* | 583 base::OneShotTimer<ModelAssociationManager>* |
| 577 ModelAssociationManager::GetTimerForTesting() { | 584 ModelAssociationManager::GetTimerForTesting() { |
| 578 return &timer_; | 585 return &timer_; |
| 579 } | 586 } |
| 580 | 587 |
| 581 } // namespace browser_sync | 588 } // namespace browser_sync |
| OLD | NEW |