OLD | NEW |
1 // Copyright (C) 2013 Google Inc. | 1 // Copyright (C) 2013 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 16 matching lines...) Expand all Loading... |
27 namespace addressinput { | 27 namespace addressinput { |
28 | 28 |
29 // Stores data in memory. Sample usage: | 29 // Stores data in memory. Sample usage: |
30 // class MyClass { | 30 // class MyClass { |
31 // public: | 31 // public: |
32 // MyClass() {} | 32 // MyClass() {} |
33 // | 33 // |
34 // ~MyClass() {} | 34 // ~MyClass() {} |
35 // | 35 // |
36 // void Write() { | 36 // void Write() { |
37 // storage_.Put("key", "value"); | 37 // storage_.Put("key", make_scoped_ptr(new std::string("value"))); |
38 // } | 38 // } |
39 // | 39 // |
40 // void Read() { | 40 // void Read() { |
41 // storage_.Get("key", BuildCallback(this, &Myclass:OnDataReady)); | 41 // storage_.Get("key", BuildCallback(this, &Myclass:OnDataReady)); |
42 // } | 42 // } |
43 // | 43 // |
44 // private: | 44 // private: |
45 // void OnDataReady(bool success, | 45 // void OnDataReady(bool success, |
46 // const std::string& key, | 46 // const std::string& key, |
47 // const std::string& data) { | 47 // const std::string& data) { |
48 // ... | 48 // ... |
49 // } | 49 // } |
50 // | 50 // |
51 // FakeStorage storage_; | 51 // FakeStorage storage_; |
52 // | 52 // |
53 // DISALLOW_COPY_AND_ASSIGN(MyClass); | 53 // DISALLOW_COPY_AND_ASSIGN(MyClass); |
54 // }; | 54 // }; |
55 class FakeStorage : public Storage { | 55 class FakeStorage : public Storage { |
56 public: | 56 public: |
57 FakeStorage(); | 57 FakeStorage(); |
58 virtual ~FakeStorage(); | 58 virtual ~FakeStorage(); |
59 | 59 |
60 // Storage implementation. | 60 // Storage implementation. |
61 virtual void Put(const std::string& key, const std::string& data); | 61 virtual void Put(const std::string& key, scoped_ptr<std::string> data); |
62 virtual void Get(const std::string& key, scoped_ptr<Callback> data_ready) | 62 virtual void Get(const std::string& key, scoped_ptr<Callback> data_ready) |
63 const; | 63 const; |
64 | 64 |
65 private: | 65 private: |
66 std::map<std::string, std::string> data_; | 66 std::map<std::string, std::string> data_; |
67 }; | 67 }; |
68 | 68 |
69 } // namespace addressinput | 69 } // namespace addressinput |
70 } // namespace i18n | 70 } // namespace i18n |
71 | 71 |
72 #endif // I18N_ADDRESSINPUT_FAKE_STORAGE_H_ | 72 #endif // I18N_ADDRESSINPUT_FAKE_STORAGE_H_ |
OLD | NEW |