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

Side by Side Diff: chrome/browser/chromeos/contacts/fake_contact_database.h

Issue 10850033: contacts: Add ContactStoreFactory and FakeContactStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix GoogleContactStore db-saving bug and FakeContactDatabase partial-update bug and apply review fe… Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_DATABASE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_DATABASE_H_
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_DATABASE_H_ 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_DATABASE_H_
7 7
8 #include "chrome/browser/chromeos/contacts/contact_database.h" 8 #include "chrome/browser/chromeos/contacts/contact_database.h"
9 9
10 #include "chrome/browser/chromeos/contacts/contact.pb.h" 10 #include "chrome/browser/chromeos/contacts/contact.pb.h"
11 11
12 namespace contacts { 12 namespace contacts {
13 13
14 // Fake implementation used for testing. 14 // Fake implementation used for testing.
15 class FakeContactDatabase : public ContactDatabaseInterface { 15 class FakeContactDatabase : public ContactDatabaseInterface {
16 public: 16 public:
17 FakeContactDatabase(); 17 FakeContactDatabase();
18 18
19 const ScopedVector<Contact>& contacts() const { return contacts_; } 19 const ScopedVector<Contact>& contacts() const { return contacts_; }
20 20
21 void set_init_success(bool success) { init_success_ = success; } 21 void set_init_success(bool success) { init_success_ = success; }
22 void set_save_success(bool success) { save_success_ = success; } 22 void set_save_success(bool success) { save_success_ = success; }
23 void set_load_success(bool success) { load_success_ = success; } 23 void set_load_success(bool success) { load_success_ = success; }
24 24
25 int num_saved_contacts() const { return num_saved_contacts_; }
26 void reset_stats() { num_saved_contacts_ = 0; }
27
25 // Copies |contacts| into |contacts_| and |metadata| into |metadata_|. These 28 // Copies |contacts| into |contacts_| and |metadata| into |metadata_|. These
26 // values will be returned by subsequent calls to LoadContacts(). 29 // values will be returned by subsequent calls to LoadContacts().
27 void SetContacts(const ContactPointers& contacts, 30 void SetContacts(const ContactPointers& contacts,
28 const UpdateMetadata& metadata); 31 const UpdateMetadata& metadata);
29 32
30 // ContactDatabaseInterface implementation. 33 // ContactDatabaseInterface implementation.
31 virtual void DestroyOnUIThread() OVERRIDE; 34 virtual void DestroyOnUIThread() OVERRIDE;
32 virtual void Init(const FilePath& database_dir, 35 virtual void Init(const FilePath& database_dir,
33 InitCallback callback) OVERRIDE; 36 InitCallback callback) OVERRIDE;
34 virtual void SaveContacts(scoped_ptr<ContactPointers> contacts, 37 virtual void SaveContacts(scoped_ptr<ContactPointers> contacts,
35 scoped_ptr<UpdateMetadata> metadata, 38 scoped_ptr<UpdateMetadata> metadata,
36 bool is_full_update, 39 bool is_full_update,
37 SaveCallback callback) OVERRIDE; 40 SaveCallback callback) OVERRIDE;
38 virtual void LoadContacts(LoadCallback callback) OVERRIDE; 41 virtual void LoadContacts(LoadCallback callback) OVERRIDE;
39 42
40 protected: 43 protected:
41 virtual ~FakeContactDatabase(); 44 virtual ~FakeContactDatabase();
42 45
43 private: 46 private:
47 // Merges |updated_contacts| into |contacts_|.
48 void MergeContacts(const ContactPointers& updated_contacts);
49
44 // Should we report success in response to various requests? 50 // Should we report success in response to various requests?
45 bool init_success_; 51 bool init_success_;
46 bool save_success_; 52 bool save_success_;
47 bool load_success_; 53 bool load_success_;
48 54
55 // Total number of contacts that have been passed to SaveContacts() while
56 // |save_success_| is true.
57 int num_saved_contacts_;
58
49 // Currently-stored contacts and metadata. 59 // Currently-stored contacts and metadata.
50 ScopedVector<Contact> contacts_; 60 ScopedVector<Contact> contacts_;
51 UpdateMetadata metadata_; 61 UpdateMetadata metadata_;
52 62
53 DISALLOW_COPY_AND_ASSIGN(FakeContactDatabase); 63 DISALLOW_COPY_AND_ASSIGN(FakeContactDatabase);
54 }; 64 };
55 65
56 } // namespace contacts 66 } // namespace contacts
57 67
58 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_DATABASE_H_ 68 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698