Roll src/third_party/WebKit 9301d6f:4619053 (svn 201058:201059)
[chromium-blink-merge.git] / extensions / renderer / activity_log_converter_strategy.h
blobfd7a1d2babf87cf2f0355f8ff34d1123c022aa18
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_RENDERER_ACTIVITY_LOG_CONVERTER_STRATEGY_H_
6 #define EXTENSIONS_RENDERER_ACTIVITY_LOG_CONVERTER_STRATEGY_H_
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "content/public/child/v8_value_converter.h"
11 #include "v8/include/v8.h"
13 namespace extensions {
15 // This class is used by activity logger and extends behavior of
16 // V8ValueConverter. It overwrites conversion of V8 arrays and objects. When
17 // converting arrays and objects, we must not invoke any JS code which may
18 // result in triggering activity logger. In such case, the log entries will be
19 // generated due to V8 object conversion rather than extension activity.
20 class ActivityLogConverterStrategy
21 : public content::V8ValueConverter::Strategy {
22 public:
23 typedef content::V8ValueConverter::Strategy::FromV8ValueCallback
24 FromV8ValueCallback;
26 ActivityLogConverterStrategy();
27 ~ActivityLogConverterStrategy() override;
29 // content::V8ValueConverter::Strategy implementation.
30 bool FromV8Object(v8::Local<v8::Object> value,
31 base::Value** out,
32 v8::Isolate* isolate,
33 const FromV8ValueCallback& callback) const override;
34 bool FromV8Array(v8::Local<v8::Array> value,
35 base::Value** out,
36 v8::Isolate* isolate,
37 const FromV8ValueCallback& callback) const override;
39 private:
40 bool FromV8Internal(v8::Local<v8::Object> value,
41 base::Value** out,
42 v8::Isolate* isolate,
43 const FromV8ValueCallback& callback) const;
45 DISALLOW_COPY_AND_ASSIGN(ActivityLogConverterStrategy);
48 } // namespace extensions
50 #endif // EXTENSIONS_RENDERER_ACTIVITY_LOG_CONVERTER_STRATEGY_H_