summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_connection.h
blob: 42269c4164eab67f94a4c101f5b9114dbb53a602 (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
51
52
53
54
55
// Copyright 2015 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.

#ifndef CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CONNECTION_H_
#define CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CONNECTION_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/api_resource.h"
#include "extensions/browser/api/api_resource_manager.h"

namespace proximity_auth {
class Connection;
}  // namespace proximity_auth

namespace extensions {
// An ApiResource wrapper for a proximity_auth::Connection.
class EasyUnlockPrivateConnection : public ApiResource {
 public:
  EasyUnlockPrivateConnection(
      bool persistent,
      const std::string& owner_extension_id,
      scoped_ptr<proximity_auth::Connection> connection);
  ~EasyUnlockPrivateConnection() override;

  // Returns a pointer to the underlying connection object.
  proximity_auth::Connection* GetConnection() const;

  // ApiResource override.
  bool IsPersistent() const override;

  // This resource should be managed on the UI thread.
  static const content::BrowserThread::ID kThreadId =
      content::BrowserThread::UI;

 private:
  friend class ApiResourceManager<EasyUnlockPrivateConnection>;
  static const char* service_name() {
    return "EasyUnlockPrivateConnectionManager";
  }

  // True, if this resource should be persistent.
  bool persistent_;

  // The connection is owned by this instance and will automatically disconnect
  // when deleted.
  scoped_ptr<proximity_auth::Connection> connection_;

  DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateConnection);
};

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CONNECTION_H_