OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DEVICE_NFC_NFC_PEER_CHROMEOS_H_ | 5 #ifndef DEVICE_NFC_NFC_PEER_CHROMEOS_H_ |
6 #define DEVICE_NFC_NFC_PEER_CHROMEOS_H_ | 6 #define DEVICE_NFC_NFC_PEER_CHROMEOS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "chromeos/dbus/nfc_record_client.h" | 12 #include "chromeos/dbus/nfc_record_client.h" |
13 #include "dbus/object_path.h" | 13 #include "dbus/object_path.h" |
14 #include "device/nfc/nfc_ndef_record.h" | 14 #include "device/nfc/nfc_ndef_record.h" |
15 #include "device/nfc/nfc_peer.h" | 15 #include "device/nfc/nfc_peer.h" |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 | 18 |
19 // The NfcPeerChromeOS class implements NfcPeer for the Chrome OS platform. | 19 // The NfcPeerChromeOS class implements NfcPeer for the Chrome OS platform. |
20 class NfcPeerChromeOS : public device::NfcPeer, | 20 class NfcPeerChromeOS : public device::NfcPeer, |
21 public NfcRecordClient::Observer { | 21 public NfcRecordClient::Observer { |
22 public: | 22 public: |
23 // NfcPeer overrides. | 23 // NfcPeer overrides. |
24 virtual void AddObserver(device::NfcPeer::Observer* observer) OVERRIDE; | 24 virtual void AddObserver(device::NfcPeer::Observer* observer) override; |
25 virtual void RemoveObserver(device::NfcPeer::Observer* observer) OVERRIDE; | 25 virtual void RemoveObserver(device::NfcPeer::Observer* observer) override; |
26 virtual std::string GetIdentifier() const OVERRIDE; | 26 virtual std::string GetIdentifier() const override; |
27 virtual const device::NfcNdefMessage& GetNdefMessage() const OVERRIDE; | 27 virtual const device::NfcNdefMessage& GetNdefMessage() const override; |
28 virtual void PushNdef(const device::NfcNdefMessage& message, | 28 virtual void PushNdef(const device::NfcNdefMessage& message, |
29 const base::Closure& callback, | 29 const base::Closure& callback, |
30 const ErrorCallback& error_callback) OVERRIDE; | 30 const ErrorCallback& error_callback) override; |
31 virtual void StartHandover(HandoverType handover_type, | 31 virtual void StartHandover(HandoverType handover_type, |
32 const base::Closure& callback, | 32 const base::Closure& callback, |
33 const ErrorCallback& error_callback) OVERRIDE; | 33 const ErrorCallback& error_callback) override; |
34 | 34 |
35 private: | 35 private: |
36 friend class NfcAdapterChromeOS; | 36 friend class NfcAdapterChromeOS; |
37 | 37 |
38 // Mapping from D-Bus object paths to NfcNdefRecord objects. | 38 // Mapping from D-Bus object paths to NfcNdefRecord objects. |
39 typedef std::map<dbus::ObjectPath, device::NfcNdefRecord*> NdefRecordMap; | 39 typedef std::map<dbus::ObjectPath, device::NfcNdefRecord*> NdefRecordMap; |
40 | 40 |
41 explicit NfcPeerChromeOS(const dbus::ObjectPath& object_path); | 41 explicit NfcPeerChromeOS(const dbus::ObjectPath& object_path); |
42 virtual ~NfcPeerChromeOS(); | 42 virtual ~NfcPeerChromeOS(); |
43 | 43 |
44 // NfcRecordClient::Observer overrides. | 44 // NfcRecordClient::Observer overrides. |
45 virtual void RecordAdded(const dbus::ObjectPath& object_path) OVERRIDE; | 45 virtual void RecordAdded(const dbus::ObjectPath& object_path) override; |
46 virtual void RecordRemoved(const dbus::ObjectPath& object_path) OVERRIDE; | 46 virtual void RecordRemoved(const dbus::ObjectPath& object_path) override; |
47 virtual void RecordPropertiesReceived( | 47 virtual void RecordPropertiesReceived( |
48 const dbus::ObjectPath& object_path) OVERRIDE; | 48 const dbus::ObjectPath& object_path) override; |
49 | 49 |
50 // Called by dbus:: on completion of the D-Bus method call to push an NDEF. | 50 // Called by dbus:: on completion of the D-Bus method call to push an NDEF. |
51 void OnPushNdef(const base::Closure& callback); | 51 void OnPushNdef(const base::Closure& callback); |
52 void OnPushNdefError(const ErrorCallback& error_callback, | 52 void OnPushNdefError(const ErrorCallback& error_callback, |
53 const std::string& error_name, | 53 const std::string& error_name, |
54 const std::string& error_message); | 54 const std::string& error_message); |
55 | 55 |
56 // Creates a record object for the record with object path |object_path| and | 56 // Creates a record object for the record with object path |object_path| and |
57 // notifies the observers, if a record object did not already exist for it. | 57 // notifies the observers, if a record object did not already exist for it. |
58 void AddRecord(const dbus::ObjectPath& object_path); | 58 void AddRecord(const dbus::ObjectPath& object_path); |
(...skipping 13 matching lines...) Expand all Loading... |
72 // Note: This should remain the last member so it'll be destroyed and | 72 // Note: This should remain the last member so it'll be destroyed and |
73 // invalidate its weak pointers before any other members are destroyed. | 73 // invalidate its weak pointers before any other members are destroyed. |
74 base::WeakPtrFactory<NfcPeerChromeOS> weak_ptr_factory_; | 74 base::WeakPtrFactory<NfcPeerChromeOS> weak_ptr_factory_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(NfcPeerChromeOS); | 76 DISALLOW_COPY_AND_ASSIGN(NfcPeerChromeOS); |
77 }; | 77 }; |
78 | 78 |
79 } // namespace chromeos | 79 } // namespace chromeos |
80 | 80 |
81 #endif // DEVICE_NFC_NFC_PEER_CHROMEOS_H_ | 81 #endif // DEVICE_NFC_NFC_PEER_CHROMEOS_H_ |
OLD | NEW |