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

Side by Side Diff: chrome/browser/extensions/extension_activity_log.h

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 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
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_EXTENSIONS_EXTENSION_ACTIVITY_LOG_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTIVITY_LOG_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTIVITY_LOG_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTIVITY_LOG_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/observer_list_threadsafe.h" 12 #include "base/observer_list_threadsafe.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 14
15 namespace extensions {
15 class Extension; 16 class Extension;
17 }
16 18
17 // A utility for tracing interesting activity for each extension. 19 // A utility for tracing interesting activity for each extension.
18 class ExtensionActivityLog { 20 class ExtensionActivityLog {
19 public: 21 public:
20 enum Activity { 22 enum Activity {
21 ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called. 23 ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called.
22 ACTIVITY_EXTENSION_API_BLOCK // Extension API invocation is blocked. 24 ACTIVITY_EXTENSION_API_BLOCK // Extension API invocation is blocked.
23 }; 25 };
24 26
25 // Observers can listen for activity events. 27 // Observers can listen for activity events.
26 class Observer { 28 class Observer {
27 public: 29 public:
28 virtual void OnExtensionActivity(const Extension* extension, 30 virtual void OnExtensionActivity(const extensions::Extension* extension,
29 Activity activity, 31 Activity activity,
30 const std::string& msg) = 0; 32 const std::string& msg) = 0;
31 }; 33 };
32 34
33 ~ExtensionActivityLog(); 35 ~ExtensionActivityLog();
34 static ExtensionActivityLog* GetInstance(); 36 static ExtensionActivityLog* GetInstance();
35 37
36 // Add/remove observer. 38 // Add/remove observer.
37 void AddObserver(const Extension* extension, Observer* observer); 39 void AddObserver(const extensions::Extension* extension, Observer* observer);
38 void RemoveObserver(const Extension* extension, Observer* observer); 40 void RemoveObserver(const extensions::Extension* extension,
41 Observer* observer);
39 42
40 // Check for the existence observer list by extension_id. 43 // Check for the existence observer list by extension_id.
41 bool HasObservers(const Extension* extension) const; 44 bool HasObservers(const extensions::Extension* extension) const;
42 45
43 // Log |activity| for |extension|. 46 // Log |activity| for |extension|.
44 void Log(const Extension* extension, 47 void Log(const extensions::Extension* extension,
45 Activity activity, 48 Activity activity,
46 const std::string& msg) const; 49 const std::string& msg) const;
47 50
48 private: 51 private:
49 ExtensionActivityLog(); 52 ExtensionActivityLog();
50 friend struct DefaultSingletonTraits<ExtensionActivityLog>; 53 friend struct DefaultSingletonTraits<ExtensionActivityLog>;
51 54
52 static const char* ActivityToString(Activity activity); 55 static const char* ActivityToString(Activity activity);
53 56
54 // A lock used to synchronize access to member variables. 57 // A lock used to synchronize access to member variables.
55 mutable base::Lock lock_; 58 mutable base::Lock lock_;
56 59
57 // Whether to log activity to stdout. This is set by checking the 60 // Whether to log activity to stdout. This is set by checking the
58 // enable-extension-activity-logging switch. 61 // enable-extension-activity-logging switch.
59 bool log_activity_to_stdout_; 62 bool log_activity_to_stdout_;
60 63
61 typedef ObserverListThreadSafe<Observer> ObserverList; 64 typedef ObserverListThreadSafe<Observer> ObserverList;
62 typedef std::map<const Extension*, scoped_refptr<ObserverList> > ObserverMap; 65 typedef std::map<const extensions::Extension*, scoped_refptr<ObserverList> >
66 ObserverMap;
63 // A map of extensions to activity observers for that extension. 67 // A map of extensions to activity observers for that extension.
64 ObserverMap observers_; 68 ObserverMap observers_;
65 69
66 DISALLOW_COPY_AND_ASSIGN(ExtensionActivityLog); 70 DISALLOW_COPY_AND_ASSIGN(ExtensionActivityLog);
67 }; 71 };
68 72
69 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTIVITY_LOG_H_ 73 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTIVITY_LOG_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/execute_code_in_tab_function.cc ('k') | chrome/browser/extensions/extension_activity_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698