Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: chromeos/dbus/fake_nfc_record_client.h

Issue 2292703002: chromeos: Remove unused NFC D-Bus client library (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/dbus/fake_nfc_manager_client.cc ('k') | chromeos/dbus/fake_nfc_record_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_DBUS_FAKE_NFC_RECORD_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_NFC_RECORD_CLIENT_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/observer_list.h"
12 #include "base/values.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/nfc_record_client.h"
15 #include "dbus/object_path.h"
16
17 namespace chromeos {
18
19 // FakeNfcRecordClient simulates the behavior of the NFC record objects and is
20 // used both in test cases in place of a mock and on the Linux desktop.
21 class CHROMEOS_EXPORT FakeNfcRecordClient : public NfcRecordClient {
22 public:
23 // Paths of the records exposed.
24 static const char kDeviceSmartPosterRecordPath[];
25 static const char kDeviceTextRecordPath[];
26 static const char kDeviceUriRecordPath[];
27 static const char kTagRecordPath[];
28
29 // Properties structure that provides fake behavior for D-Bus calls.
30 struct Properties : public NfcRecordClient::Properties {
31 explicit Properties(const PropertyChangedCallback& callback);
32 ~Properties() override;
33
34 // dbus::PropertySet overrides.
35 void Get(dbus::PropertyBase* property,
36 dbus::PropertySet::GetCallback callback) override;
37 void GetAll() override;
38 void Set(dbus::PropertyBase* property,
39 dbus::PropertySet::SetCallback callback) override;
40 };
41
42 FakeNfcRecordClient();
43 ~FakeNfcRecordClient() override;
44
45 // NfcTagClient overrides.
46 void Init(dbus::Bus* bus) override;
47 void AddObserver(Observer* observer) override;
48 void RemoveObserver(Observer* observer) override;
49 std::vector<dbus::ObjectPath> GetRecordsForDevice(
50 const dbus::ObjectPath& device_path) override;
51 std::vector<dbus::ObjectPath> GetRecordsForTag(
52 const dbus::ObjectPath& tag_path) override;
53 Properties* GetProperties(const dbus::ObjectPath& object_path) override;
54
55 // Adds or removes the fake record objects and notifies the observers.
56 void SetDeviceRecordsVisible(bool visible);
57 void SetTagRecordsVisible(bool visible);
58
59 // Modifies the contents of the tag record. |attributes| should be the
60 // same as the argument to NfcTagClient::Write. Each field will be directly
61 // assigned to the underlying record based on the type property, with
62 // no validity checking. Invalid tag content can be passed here to test
63 // the case where the remote application returns an incorrectly formatted
64 // record.
65 bool WriteTagRecord(const base::DictionaryValue& attributes);
66
67 private:
68 // Property changed callback passed when we create Properties* structures.
69 void OnPropertyChanged(const dbus::ObjectPath& object_path,
70 const std::string& property_name);
71
72 // Called by Properties* structures when GetAll is called.
73 void OnPropertiesReceived(const dbus::ObjectPath& object_path);
74
75 // If true, the records are currently visible.
76 bool device_records_visible_;
77 bool tag_records_visible_;
78
79 // List of observers interested in event notifications from us.
80 base::ObserverList<Observer> observers_;
81
82 // Fake properties that are returned for the fake records.
83 std::unique_ptr<Properties> device_smart_poster_record_properties_;
84 std::unique_ptr<Properties> device_text_record_properties_;
85 std::unique_ptr<Properties> device_uri_record_properties_;
86 std::unique_ptr<Properties> tag_record_properties_;
87
88 DISALLOW_COPY_AND_ASSIGN(FakeNfcRecordClient);
89 };
90
91 } // namespace chromeos
92
93 #endif // CHROMEOS_DBUS_FAKE_NFC_RECORD_CLIENT_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_nfc_manager_client.cc ('k') | chromeos/dbus/fake_nfc_record_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698