Logo Search packages:      
Sourcecode: chromium-browser version File versions  Download package


// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.


#include "chrome/browser/sync/glue/data_type_manager.h"

#include <map>
#include <vector>

#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/task.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_type.h"

class NotificationSource;
class NotificationDetails;

namespace browser_sync {

class DataTypeController;
class SyncBackendHost;

class DataTypeManagerImpl : public DataTypeManager,
                            public NotificationObserver {
  DataTypeManagerImpl(SyncBackendHost* backend,
                      const DataTypeController::TypeMap& controllers);
  virtual ~DataTypeManagerImpl();

  // DataTypeManager interface.
  virtual void Configure(const TypeSet& desired_types);

  virtual void Stop();

  virtual const DataTypeController::TypeMap& controllers() {
    return controllers_;

  virtual State state() {
    return state_;

  // NotificationObserver implementation.
  virtual void Observe(NotificationType type,
                       const NotificationSource& source,
                       const NotificationDetails& details);

  // Starts the next data type in the kStartOrder list, indicated by
  // the current_type_ member.  If there are no more data types to
  // start, the stashed start_callback_ is invoked.
  void StartNextType();

  // Callback passed to each data type controller on startup.
  void TypeStartCallback(DataTypeController::StartResult result);

  // Stops all data types.
  void FinishStop();
  void FinishStopAndNotify(ConfigureResult result);

  void Restart();
  void DownloadReady();
  void AddObserver(NotificationType type);
  void RemoveObserver(NotificationType type);
  void NotifyStart();
  void NotifyDone(ConfigureResult result);
  void ResumeSyncer();
  void PauseSyncer();

  SyncBackendHost* backend_;
  // Map of all data type controllers that are available for sync.
  // This list is determined at startup by various command line flags.
  const DataTypeController::TypeMap controllers_;
  State state_;
  DataTypeController* current_dtc_;
  std::map<syncable::ModelType, int> start_order_;
  TypeSet last_requested_types_;
  std::vector<DataTypeController*> needs_start_;
  std::vector<DataTypeController*> needs_stop_;

  NotificationRegistrar notification_registrar_;
  ScopedRunnableMethodFactory<DataTypeManagerImpl> method_factory_;


}  // namespace browser_sync


Generated by  Doxygen 1.6.0   Back to index