summaryrefslogtreecommitdiffstats
path: root/sync/internal_api/sync_core_proxy.cc
blob: 5ba3135f6da83db31994ee9e2437204a9d8588e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2014 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 "sync/internal_api/public/sync_core_proxy.h"

#include "base/bind.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "sync/internal_api/sync_core.h"

namespace syncer {

SyncCoreProxy::SyncCoreProxy(
    scoped_refptr<base::SequencedTaskRunner> sync_task_runner,
    base::WeakPtr<SyncCore> sync_core)
    : sync_task_runner_(sync_task_runner),
      sync_core_(sync_core) {}

SyncCoreProxy::~SyncCoreProxy() {}

void SyncCoreProxy::ConnectTypeToCore(
    ModelType type,
    base::WeakPtr<NonBlockingTypeProcessor> type_processor) {
  VLOG(1) << "ConnectSyncTypeToCore: " << ModelTypeToString(type);
  sync_task_runner_->PostTask(
      FROM_HERE,
      base::Bind(&SyncCore::ConnectSyncTypeToCore,
                 sync_core_,
                 type,
                 base::MessageLoopProxy::current(),
                 type_processor));
}

SyncCoreProxy SyncCoreProxy::GetInvalidSyncCoreProxyForTest() {
  return SyncCoreProxy(scoped_refptr<base::SequencedTaskRunner>(),
                       base::WeakPtr<SyncCore>());
}

}  // namespace syncer