OLD | NEW |
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 EXTENSIONS_RENDERER_API_ACTIVITY_LOGGER_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_ACTIVITY_LOGGER_H_ |
6 #define EXTENSIONS_RENDERER_API_ACTIVITY_LOGGER_H_ | 6 #define EXTENSIONS_RENDERER_API_ACTIVITY_LOGGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "extensions/common/features/feature.h" | 11 #include "extensions/common/features/feature.h" |
12 #include "extensions/renderer/object_backed_native_handler.h" | 12 #include "extensions/renderer/object_backed_native_handler.h" |
13 #include "v8/include/v8.h" | 13 #include "v8/include/v8.h" |
14 | 14 |
15 namespace extensions { | 15 namespace extensions { |
| 16 class Dispatcher; |
16 | 17 |
17 // Used to log extension API calls and events that are implemented with custom | 18 // Used to log extension API calls and events that are implemented with custom |
18 // bindings.The actions are sent via IPC to extensions::ActivityLog for | 19 // bindings.The actions are sent via IPC to extensions::ActivityLog for |
19 // recording and display. | 20 // recording and display. |
20 class APIActivityLogger : public ObjectBackedNativeHandler { | 21 class APIActivityLogger : public ObjectBackedNativeHandler { |
21 public: | 22 public: |
22 explicit APIActivityLogger(ScriptContext* context); | 23 APIActivityLogger(ScriptContext* context, Dispatcher* dispatcher); |
| 24 ~APIActivityLogger() override; |
23 | 25 |
24 private: | 26 private: |
25 // Used to distinguish API calls & events from each other in LogInternal. | 27 // Used to distinguish API calls & events from each other in LogInternal. |
26 enum CallType { APICALL, EVENT }; | 28 enum CallType { APICALL, EVENT }; |
27 | 29 |
28 // This is ultimately invoked in bindings.js with JavaScript arguments. | 30 // This is ultimately invoked in bindings.js with JavaScript arguments. |
29 // arg0 - extension ID as a string | 31 // arg0 - extension ID as a string |
30 // arg1 - API call name as a string | 32 // arg1 - API call name as a string |
31 // arg2 - arguments to the API call | 33 // arg2 - arguments to the API call |
32 // arg3 - any extra logging info as a string (optional) | 34 // arg3 - any extra logging info as a string (optional) |
33 static void LogAPICall(const v8::FunctionCallbackInfo<v8::Value>& args); | 35 void LogAPICall(const v8::FunctionCallbackInfo<v8::Value>& args); |
34 | 36 |
35 // This is ultimately invoked in bindings.js with JavaScript arguments. | 37 // This is ultimately invoked in bindings.js with JavaScript arguments. |
36 // arg0 - extension ID as a string | 38 // arg0 - extension ID as a string |
37 // arg1 - Event name as a string | 39 // arg1 - Event name as a string |
38 // arg2 - Event arguments | 40 // arg2 - Event arguments |
39 // arg3 - any extra logging info as a string (optional) | 41 // arg3 - any extra logging info as a string (optional) |
40 static void LogEvent(const v8::FunctionCallbackInfo<v8::Value>& args); | 42 void LogEvent(const v8::FunctionCallbackInfo<v8::Value>& args); |
41 | 43 |
42 // LogAPICall and LogEvent are really the same underneath except for | 44 // LogAPICall and LogEvent are really the same underneath except for |
43 // how they are ultimately dispatched to the log. | 45 // how they are ultimately dispatched to the log. |
44 static void LogInternal(const CallType call_type, | 46 void LogInternal(const CallType call_type, |
45 const v8::FunctionCallbackInfo<v8::Value>& args); | 47 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 48 |
| 49 Dispatcher* dispatcher_; |
46 | 50 |
47 DISALLOW_COPY_AND_ASSIGN(APIActivityLogger); | 51 DISALLOW_COPY_AND_ASSIGN(APIActivityLogger); |
48 }; | 52 }; |
49 | 53 |
50 } // namespace extensions | 54 } // namespace extensions |
51 | 55 |
52 #endif // EXTENSIONS_RENDERER_API_ACTIVITY_LOGGER_H_ | 56 #endif // EXTENSIONS_RENDERER_API_ACTIVITY_LOGGER_H_ |
OLD | NEW |