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

Side by Side Diff: webkit/extensions/v8/benchmarking_extension.cc

Issue 2819037: Show a warning message if the cache might not be cleared between runs. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 5 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
« no previous file with comments | « chrome/renderer/renderer_glue.cc ('k') | webkit/glue/webkit_glue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/command_line.h"
5 #include "base/stats_table.h" 6 #include "base/stats_table.h"
6 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" 7 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
7 #include "webkit/extensions/v8/benchmarking_extension.h" 8 #include "webkit/extensions/v8/benchmarking_extension.h"
8 #include "webkit/glue/webkit_glue.h" 9 #include "webkit/glue/webkit_glue.h"
9 10
10 using WebKit::WebCache; 11 using WebKit::WebCache;
11 12
12 namespace extensions_v8 { 13 namespace extensions_v8 {
13 14
14 const char* kBenchmarkingExtensionName = "v8/Benchmarking"; 15 const char* kBenchmarkingExtensionName = "v8/Benchmarking";
(...skipping 13 matching lines...) Expand all
28 " ClearCache();" 29 " ClearCache();"
29 "};" 30 "};"
30 "chrome.benchmarking.closeConnections = function() {" 31 "chrome.benchmarking.closeConnections = function() {"
31 " native function CloseConnections();" 32 " native function CloseConnections();"
32 " CloseConnections();" 33 " CloseConnections();"
33 "};" 34 "};"
34 "chrome.benchmarking.counter = function(name) {" 35 "chrome.benchmarking.counter = function(name) {"
35 " native function GetCounter();" 36 " native function GetCounter();"
36 " return GetCounter(name);" 37 " return GetCounter(name);"
37 "};" 38 "};"
39 "chrome.benchmarking.isSingleProcess = function() {"
40 " native function IsSingleProcess();"
41 " return IsSingleProcess();"
42 "};"
38 ) {} 43 ) {}
39 44
40 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 45 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
41 v8::Handle<v8::String> name) { 46 v8::Handle<v8::String> name) {
42 if (name->Equals(v8::String::New("CloseConnections"))) { 47 if (name->Equals(v8::String::New("CloseConnections"))) {
43 return v8::FunctionTemplate::New(CloseConnections); 48 return v8::FunctionTemplate::New(CloseConnections);
44 } else if (name->Equals(v8::String::New("ClearCache"))) { 49 } else if (name->Equals(v8::String::New("ClearCache"))) {
45 return v8::FunctionTemplate::New(ClearCache); 50 return v8::FunctionTemplate::New(ClearCache);
46 } else if (name->Equals(v8::String::New("GetCounter"))) { 51 } else if (name->Equals(v8::String::New("GetCounter"))) {
47 return v8::FunctionTemplate::New(GetCounter); 52 return v8::FunctionTemplate::New(GetCounter);
53 } else if (name->Equals(v8::String::New("IsSingleProcess"))) {
54 return v8::FunctionTemplate::New(IsSingleProcess);
48 } 55 }
49 return v8::Handle<v8::FunctionTemplate>(); 56 return v8::Handle<v8::FunctionTemplate>();
50 } 57 }
51 58
52 static v8::Handle<v8::Value> CloseConnections(const v8::Arguments& args) { 59 static v8::Handle<v8::Value> CloseConnections(const v8::Arguments& args) {
53 webkit_glue::CloseCurrentConnections(); 60 webkit_glue::CloseCurrentConnections();
54 return v8::Undefined(); 61 return v8::Undefined();
55 } 62 }
56 63
57 static v8::Handle<v8::Value> ClearCache(const v8::Arguments& args) { 64 static v8::Handle<v8::Value> ClearCache(const v8::Arguments& args) {
58 webkit_glue::ClearCache(); 65 webkit_glue::ClearCache();
59 WebCache::clear(); 66 WebCache::clear();
60 return v8::Undefined(); 67 return v8::Undefined();
61 } 68 }
62 69
63 static v8::Handle<v8::Value> GetCounter(const v8::Arguments& args) { 70 static v8::Handle<v8::Value> GetCounter(const v8::Arguments& args) {
64 if (!args.Length() || !args[0]->IsString() || !StatsTable::current()) 71 if (!args.Length() || !args[0]->IsString() || !StatsTable::current())
65 return v8::Undefined(); 72 return v8::Undefined();
66 73
67 // Extract the name argument 74 // Extract the name argument
68 char name[256]; 75 char name[256];
69 name[0] = 'c'; 76 name[0] = 'c';
70 name[1] = ':'; 77 name[1] = ':';
71 args[0]->ToString()->WriteAscii(&name[2], 0, sizeof(name) - 3); 78 args[0]->ToString()->WriteAscii(&name[2], 0, sizeof(name) - 3);
72 79
73 int counter = StatsTable::current()->GetCounterValue(name); 80 int counter = StatsTable::current()->GetCounterValue(name);
74 return v8::Integer::New(counter); 81 return v8::Integer::New(counter);
75 } 82 }
83
84 static v8::Handle<v8::Value> IsSingleProcess(const v8::Arguments& args) {
85 return v8::Boolean::New(webkit_glue::IsSingleProcess());
86 }
76 }; 87 };
77 88
78 v8::Extension* BenchmarkingExtension::Get() { 89 v8::Extension* BenchmarkingExtension::Get() {
79 return new BenchmarkingWrapper(); 90 return new BenchmarkingWrapper();
80 } 91 }
81 92
82 } // namespace extensions_v8 93 } // namespace extensions_v8
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_glue.cc ('k') | webkit/glue/webkit_glue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698