| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/renderer/benchmarking_extension.h" | 5 #include "chrome/renderer/benchmarking_extension.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/stats_table.h" | 8 #include "base/metrics/stats_table.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 /* | 80 /* |
| 81 * Extract the counter name from arguments. | 81 * Extract the counter name from arguments. |
| 82 */ | 82 */ |
| 83 static void ExtractCounterName( | 83 static void ExtractCounterName( |
| 84 const v8::FunctionCallbackInfo<v8::Value>& args, | 84 const v8::FunctionCallbackInfo<v8::Value>& args, |
| 85 char* name, | 85 char* name, |
| 86 size_t capacity) { | 86 size_t capacity) { |
| 87 name[0] = 'c'; | 87 name[0] = 'c'; |
| 88 name[1] = ':'; | 88 name[1] = ':'; |
| 89 args[0]->ToString()->WriteUtf8(&name[2], capacity - 3); | 89 args[0]->ToString(args.GetIsolate())->WriteUtf8(&name[2], capacity - 3); |
| 90 } | 90 } |
| 91 | 91 |
| 92 static void GetCounter(const v8::FunctionCallbackInfo<v8::Value>& args) { | 92 static void GetCounter(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 93 if (!args.Length() || !args[0]->IsString() || !base::StatsTable::current()) | 93 if (!args.Length() || !args[0]->IsString() || !base::StatsTable::current()) |
| 94 return; | 94 return; |
| 95 | 95 |
| 96 char name[256]; | 96 char name[256]; |
| 97 ExtractCounterName(args, name, sizeof(name)); | 97 ExtractCounterName(args, name, sizeof(name)); |
| 98 int counter = base::StatsTable::current()->GetCounterValue(name); | 98 int counter = base::StatsTable::current()->GetCounterValue(name); |
| 99 args.GetReturnValue().Set(static_cast<int32_t>(counter)); | 99 args.GetReturnValue().Set(static_cast<int32_t>(counter)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 121 args.GetReturnValue().Set( | 121 args.GetReturnValue().Set( |
| 122 static_cast<double>(base::TimeTicks::HighResNow().ToInternalValue())); | 122 static_cast<double>(base::TimeTicks::HighResNow().ToInternalValue())); |
| 123 } | 123 } |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 v8::Extension* BenchmarkingExtension::Get() { | 126 v8::Extension* BenchmarkingExtension::Get() { |
| 127 return new BenchmarkingWrapper(); | 127 return new BenchmarkingWrapper(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace extensions_v8 | 130 } // namespace extensions_v8 |
| OLD | NEW |