session_data_type_controller.h revision 21d179b334e59e9a3bfcaed4c4430bef1bc5759d
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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_SYNC_GLUE_SESSION_DATA_TYPE_CONTROLLER_H_
6#define CHROME_BROWSER_SYNC_GLUE_SESSION_DATA_TYPE_CONTROLLER_H_
7#pragma once
8
9#include <string>
10
11#include "base/basictypes.h"
12#include "base/scoped_ptr.h"
13#include "chrome/browser/sync/glue/data_type_controller.h"
14#include "chrome/browser/sync/glue/session_model_associator.h"
15
16class ProfileSyncFactory;
17class ProfileSyncService;
18
19namespace browser_sync {
20
21class AssociatorInterface;
22class ChangeProcessor;
23
24class SessionDataTypeController : public DataTypeController {
25 public:
26  SessionDataTypeController(
27      ProfileSyncFactory* profile_sync_factory,
28      ProfileSyncService* sync_service);
29  virtual ~SessionDataTypeController();
30
31  // DataTypeController implementation.
32  virtual void Start(StartCallback* start_callback);
33
34  virtual void Stop();
35
36  virtual bool enabled();
37
38  virtual syncable::ModelType type();
39
40  virtual browser_sync::ModelSafeGroup model_safe_group();
41
42  virtual const char* name() const;
43
44  virtual State state();
45
46  // UnrecoverableErrorHandler interface.
47  virtual void OnUnrecoverableError(
48      const tracked_objects::Location& from_here,
49      const std::string& message);
50
51  SessionModelAssociator* GetModelAssociator();
52
53 private:
54  // Helper method to run the stashed start callback with a given result.
55  void FinishStart(StartResult result);
56
57  // Cleans up state and calls callback when start fails.
58  void StartFailed(StartResult result);
59
60  ProfileSyncFactory* profile_sync_factory_;
61  ProfileSyncService* sync_service_;
62
63  State state_;
64
65  scoped_ptr<StartCallback> start_callback_;
66  scoped_ptr<AssociatorInterface> model_associator_;
67  scoped_ptr<ChangeProcessor> change_processor_;
68
69  DISALLOW_COPY_AND_ASSIGN(SessionDataTypeController);
70};
71
72}  // namespace browser_sync
73
74#endif  // CHROME_BROWSER_SYNC_GLUE_SESSION_DATA_TYPE_CONTROLLER_H_
75
76