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

Side by Side Diff: components/password_manager/core/browser/log_router.h

Issue 264793010: Rename PasswordManagerLogger to LogReceiver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOG_ROUTER_H_ 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOG_ROUTER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOG_ROUTER_H_ 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOG_ROUTER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 13
14 namespace password_manager { 14 namespace password_manager {
15 15
16 class LogReceiver;
16 class PasswordManagerClient; 17 class PasswordManagerClient;
17 class PasswordManagerLogger;
18 18
19 // The router stands between PasswordManagerClient instances and log receivers. 19 // The router stands between PasswordManagerClient instances and log receivers.
20 // During the process of saving a password, the password manager code generates 20 // During the process of saving a password, the password manager code generates
21 // the log strings, and passes them to the router. The router distributes the 21 // the log strings, and passes them to the router. The router distributes the
22 // logs to the receivers for displaying. 22 // logs to the receivers for displaying.
23 //
24 // TODO(vabr): The receivers are objects of type PasswordManagerLogger. That
25 // type should be renamed to LogReceiver instead.
26 class LogRouter { 23 class LogRouter {
27 public: 24 public:
28 LogRouter(); 25 LogRouter();
29 virtual ~LogRouter(); 26 virtual ~LogRouter();
30 27
31 // Passes logs to the router. Only call when there are receivers registered. 28 // Passes logs to the router. Only call when there are receivers registered.
32 void ProcessLog(const std::string& text); 29 void ProcessLog(const std::string& text);
33 30
34 // All four (Unr|R)egister* methods below are safe to call from the 31 // All four (Unr|R)egister* methods below are safe to call from the
35 // constructor of the registered object, because they do not call that object, 32 // constructor of the registered object, because they do not call that object,
36 // and the router only runs on a single thread. 33 // and the router only runs on a single thread.
37 34
38 // The clients must register to be notified about whether there are some 35 // The clients must register to be notified about whether there are some
39 // receivers or not. RegisterClient adds |client| to the right observer list 36 // receivers or not. RegisterClient adds |client| to the right observer list
40 // and returns true iff there are some receivers registered. 37 // and returns true iff there are some receivers registered.
41 bool RegisterClient(PasswordManagerClient* client); 38 bool RegisterClient(PasswordManagerClient* client);
42 // Remove |client| from the observers list. 39 // Remove |client| from the observers list.
43 void UnregisterClient(PasswordManagerClient* client); 40 void UnregisterClient(PasswordManagerClient* client);
44 41
45 // The receivers must register to get updates with new logs in the future. 42 // The receivers must register to get updates with new logs in the future.
46 // RegisterReceiver adds |receiver| to the right observer list, and returns 43 // RegisterReceiver adds |receiver| to the right observer list, and returns
47 // the logs accumulated so far. (It returns by value, not const ref, to 44 // the logs accumulated so far. (It returns by value, not const ref, to
48 // provide a snapshot as opposed to a link to |accumulated_logs_|.) 45 // provide a snapshot as opposed to a link to |accumulated_logs_|.)
49 std::string RegisterReceiver(PasswordManagerLogger* receiver); 46 std::string RegisterReceiver(LogReceiver* receiver);
50 // Remove |receiver| from the observers list. 47 // Remove |receiver| from the observers list.
51 void UnregisterReceiver(PasswordManagerLogger* receiver); 48 void UnregisterReceiver(LogReceiver* receiver);
52 49
53 private: 50 private:
54 // Observer lists for clients and receivers. The |true| in the template 51 // Observer lists for clients and receivers. The |true| in the template
55 // specialisation means that they will check that all observers were removed 52 // specialisation means that they will check that all observers were removed
56 // on destruction. 53 // on destruction.
57 ObserverList<PasswordManagerClient, true> clients_; 54 ObserverList<PasswordManagerClient, true> clients_;
58 ObserverList<PasswordManagerLogger, true> receivers_; 55 ObserverList<LogReceiver, true> receivers_;
59 56
60 // Logs accumulated since the first receiver was registered. 57 // Logs accumulated since the first receiver was registered.
61 std::string accumulated_logs_; 58 std::string accumulated_logs_;
62 59
63 DISALLOW_COPY_AND_ASSIGN(LogRouter); 60 DISALLOW_COPY_AND_ASSIGN(LogRouter);
64 }; 61 };
65 62
66 } // namespace password_manager 63 } // namespace password_manager
67 64
68 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOG_ROUTER_H_ 65 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOG_ROUTER_H_
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/log_receiver.h ('k') | components/password_manager/core/browser/log_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698