Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / extensions / api / easy_unlock_private / easy_unlock_private_connection.h
blob5c4b43139a28bb456a2cd2327cb40b2094458615
1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CONNECTION_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CONNECTION_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "extensions/browser/api/api_resource.h"
10 #include "extensions/browser/api/api_resource_manager.h"
12 namespace proximity_auth {
13 class Connection;
14 } // namespace proximity_auth
16 namespace extensions {
17 // An ApiResource wrapper for a proximity_auth::Connection.
18 class EasyUnlockPrivateConnection : public ApiResource {
19 public:
20 EasyUnlockPrivateConnection(
21 bool persistent,
22 const std::string& owner_extension_id,
23 scoped_ptr<proximity_auth::Connection> connection);
24 ~EasyUnlockPrivateConnection() override;
26 // Returns a pointer to the underlying connection object.
27 proximity_auth::Connection* GetConnection() const;
29 // ApiResource override.
30 bool IsPersistent() const override;
32 // This resource should be managed on the UI thread.
33 static const content::BrowserThread::ID kThreadId =
34 content::BrowserThread::UI;
36 private:
37 friend class ApiResourceManager<EasyUnlockPrivateConnection>;
38 static const char* service_name() {
39 return "EasyUnlockPrivateConnectionManager";
42 // True, if this resource should be persistent.
43 bool persistent_;
45 // The connection is owned by this instance and will automatically disconnect
46 // when deleted.
47 scoped_ptr<proximity_auth::Connection> connection_;
49 DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateConnection);
52 } // namespace extensions
54 #endif // CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CONNECTION_H_