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

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

Issue 10896031: contacts: Add ContactManagerInterface::GetWeakPtr(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: apply review feedback Created 8 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 | 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_CONTACT_MANAGER_STUB_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_STUB_H_
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_STUB_H_ 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_STUB_H_
7 7
8 #include "chrome/browser/chromeos/contacts/contact_manager.h" 8 #include "chrome/browser/chromeos/contacts/contact_manager.h"
9 9
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 11
12 namespace contacts { 12 namespace contacts {
13 13
14 // ContactManagerInterface implementation that returns a fixed set of contacts. 14 // ContactManagerInterface implementation that returns a fixed set of contacts.
15 // Used for testing. 15 // Used for testing.
16 class ContactManagerStub : public ContactManagerInterface { 16 class ContactManagerStub : public ContactManagerInterface {
17 public: 17 public:
18 explicit ContactManagerStub(Profile* profile); 18 explicit ContactManagerStub(Profile* profile);
19 virtual ~ContactManagerStub(); 19 virtual ~ContactManagerStub();
20 20
21 // Updates |contacts_|. 21 // Updates |contacts_|.
22 void SetContacts(const ContactPointers& contacts); 22 void SetContacts(const ContactPointers& contacts);
23 23
24 // Invokes OnContactsUpdated() on |observers_|. 24 // Invokes OnContactsUpdated() on |observers_|.
25 void NotifyObserversAboutUpdatedContacts(); 25 void NotifyObserversAboutUpdatedContacts();
26 26
27 // ContactManagerInterface overrides: 27 // ContactManagerInterface overrides:
28 virtual base::WeakPtr<ContactManagerInterface> GetWeakPtr() OVERRIDE;
28 virtual void AddObserver(ContactManagerObserver* observer, Profile* profile) 29 virtual void AddObserver(ContactManagerObserver* observer, Profile* profile)
29 OVERRIDE; 30 OVERRIDE;
30 virtual void RemoveObserver(ContactManagerObserver* observer, 31 virtual void RemoveObserver(ContactManagerObserver* observer,
31 Profile* profile) OVERRIDE; 32 Profile* profile) OVERRIDE;
32 virtual scoped_ptr<ContactPointers> GetAllContacts(Profile* profile) OVERRIDE; 33 virtual scoped_ptr<ContactPointers> GetAllContacts(Profile* profile) OVERRIDE;
33 virtual const Contact* GetContactById(Profile* profile, 34 virtual const Contact* GetContactById(Profile* profile,
34 const std::string& contact_id) OVERRIDE; 35 const std::string& contact_id) OVERRIDE;
35 36
36 private: 37 private:
37 // Profile expected to be passed to ContactManagerInterface methods. 38 // Profile expected to be passed to ContactManagerInterface methods.
38 // Passing any other profile will result in a crash. 39 // Passing any other profile will result in a crash.
39 Profile* profile_; // not owned 40 Profile* profile_; // not owned
40 41
41 // Observers registered for |profile_|. 42 // Observers registered for |profile_|.
42 ObserverList<ContactManagerObserver> observers_; 43 ObserverList<ContactManagerObserver> observers_;
43 44
44 // Contacts that will be returned by GetAllContacts() and GetContactById(). 45 // Contacts that will be returned by GetAllContacts() and GetContactById().
45 ScopedVector<Contact> contacts_; 46 ScopedVector<Contact> contacts_;
46 47
48 // Note: This should remain the last member so it'll be destroyed and
49 // invalidate its weak pointers before any other members are destroyed.
50 base::WeakPtrFactory<ContactManagerInterface> weak_ptr_factory_;
51
47 DISALLOW_COPY_AND_ASSIGN(ContactManagerStub); 52 DISALLOW_COPY_AND_ASSIGN(ContactManagerStub);
48 }; 53 };
49 54
50 } // namespace contacts 55 } // namespace contacts
51 56
52 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_STUB_H_ 57 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_STUB_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_manager.cc ('k') | chrome/browser/chromeos/contacts/contact_manager_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698