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

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

Issue 1415533013: Fix password manager internals renderer reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separate dummy log manager Created 5 years, 1 month 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
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/compiler_specific.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/observer_list.h" 13 #include "base/observer_list.h"
13 14
14 namespace password_manager { 15 namespace password_manager {
15 16
17 class LogManager;
16 class LogReceiver; 18 class LogReceiver;
17 class PasswordManagerClient;
18 19
19 // The router stands between PasswordManagerClient instances and log receivers. 20 // The router stands between LogManager and LogReceiver instances. Both managers
20 // During the process of saving a password, the password manager code generates 21 // and receivers need to register (and unregister) with the router. After that,
21 // the log strings, and passes them to the router. The router distributes the 22 // the following communication is enabled:
22 // logs to the receivers for displaying. 23 // * LogManagers are notified when logging starts or stops being possible
24 // * LogReceivers are sent logs routed through LogRouter
23 class LogRouter { 25 class LogRouter {
24 public: 26 public:
25 LogRouter(); 27 LogRouter();
26 virtual ~LogRouter(); 28 ~LogRouter();
27 29
28 // Passes logs to the router. Only call when there are receivers registered. 30 // Passes logs to the router. Only call when there are receivers registered.
29 void ProcessLog(const std::string& text); 31 void ProcessLog(const std::string& text);
30 32
31 // All four (Unr|R)egister* methods below are safe to call from the 33 // All four (Unr|R)egister* methods below are safe to call from the
32 // constructor of the registered object, because they do not call that object, 34 // constructor of the registered object, because they do not call that object,
33 // and the router only runs on a single thread. 35 // and the router only runs on a single thread.
34 36
35 // The clients must register to be notified about whether there are some 37 // The managers must register to be notified about whether there are some
36 // receivers or not. RegisterClient adds |client| to the right observer list 38 // receivers or not. RegisterManager adds |manager| to the right observer list
37 // and returns true iff there are some receivers registered. 39 // and returns true iff there are some receivers registered.
38 bool RegisterClient(PasswordManagerClient* client); 40 bool RegisterManager(LogManager* manager);
39 // Remove |client| from the observers list. 41 // Remove |manager| from the observers list.
40 void UnregisterClient(PasswordManagerClient* client); 42 void UnregisterManager(LogManager* manager);
41 43
42 // The receivers must register to get updates with new logs in the future. 44 // The receivers must register to get updates with new logs in the future.
43 // RegisterReceiver adds |receiver| to the right observer list, and returns 45 // RegisterReceiver adds |receiver| to the right observer list, and returns
44 // the logs accumulated so far. (It returns by value, not const ref, to 46 // the logs accumulated so far. (It returns by value, not const ref, to
45 // provide a snapshot as opposed to a link to |accumulated_logs_|.) 47 // provide a snapshot as opposed to a link to |accumulated_logs_|.)
46 std::string RegisterReceiver(LogReceiver* receiver); 48 std::string RegisterReceiver(LogReceiver* receiver) WARN_UNUSED_RESULT;
47 // Remove |receiver| from the observers list. 49 // Remove |receiver| from the observers list.
48 void UnregisterReceiver(LogReceiver* receiver); 50 void UnregisterReceiver(LogReceiver* receiver);
49 51
50 private: 52 private:
51 // Observer lists for clients and receivers. The |true| in the template 53 // Observer lists for managers and receivers. The |true| in the template
52 // specialisation means that they will check that all observers were removed 54 // specialisation means that they will check that all observers were removed
53 // on destruction. 55 // on destruction.
54 base::ObserverList<PasswordManagerClient, true> clients_; 56 base::ObserverList<LogManager, true> managers_;
55 base::ObserverList<LogReceiver, true> receivers_; 57 base::ObserverList<LogReceiver, true> receivers_;
56 58
57 // Logs accumulated since the first receiver was registered. 59 // Logs accumulated since the first receiver was registered.
58 std::string accumulated_logs_; 60 std::string accumulated_logs_;
59 61
60 DISALLOW_COPY_AND_ASSIGN(LogRouter); 62 DISALLOW_COPY_AND_ASSIGN(LogRouter);
61 }; 63 };
62 64
63 } // namespace password_manager 65 } // namespace password_manager
64 66
65 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOG_ROUTER_H_ 67 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOG_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698