summaryrefslogtreecommitdiffstats
path: root/remoting/host/security_key/remote_security_key_ipc_server.cc
blob: 62d54c831dac777120fbdc503de158d8445be565 (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
41
42
43
44
45
46
47
48
49
50
// Copyright 2016 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 "remoting/host/security_key/remote_security_key_ipc_server.h"

#include <string>

#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
#include "remoting/base/logging.h"
#include "remoting/host/chromoting_messages.h"
#include "remoting/host/security_key/remote_security_key_ipc_server_impl.h"

namespace {

// Not thread safe, tests which set this value must do so on the same thread.
static remoting::RemoteSecurityKeyIpcServerFactory* g_factory = nullptr;

}  // namespace

namespace remoting {

void RemoteSecurityKeyIpcServer::SetFactoryForTest(
    RemoteSecurityKeyIpcServerFactory* factory) {
  g_factory = factory;
}

scoped_ptr<RemoteSecurityKeyIpcServer> RemoteSecurityKeyIpcServer::Create(
    int connection_id,
    base::TimeDelta initial_connect_timeout,
    const GnubbyAuthHandler::SendMessageCallback& message_callback,
    const base::Closure& done_callback) {
  scoped_ptr<RemoteSecurityKeyIpcServer> ipc_server =
      g_factory
          ? g_factory->Create(connection_id, initial_connect_timeout,
                              message_callback, done_callback)
          : make_scoped_ptr(new RemoteSecurityKeyIpcServerImpl(
                connection_id, initial_connect_timeout, message_callback,
                done_callback));

  return ipc_server;
}

}  // namespace remoting