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

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

Issue 2856018: Revert 51042 - Show a warning message if the cache might not be cleared corre... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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 | Annotate | Revision Log
« 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"
6 #include "base/stats_table.h" 5 #include "base/stats_table.h"
7 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" 6 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
8 #include "webkit/extensions/v8/benchmarking_extension.h" 7 #include "webkit/extensions/v8/benchmarking_extension.h"
9 #include "webkit/glue/webkit_glue.h" 8 #include "webkit/glue/webkit_glue.h"
10 9
11 using WebKit::WebCache; 10 using WebKit::WebCache;
12 11
13 namespace extensions_v8 { 12 namespace extensions_v8 {
14 13
15 const char* kBenchmarkingExtensionName = "v8/Benchmarking"; 14 const char* kBenchmarkingExtensionName = "v8/Benchmarking";
(...skipping 13 matching lines...) Expand all
29 " ClearCache();" 28 " ClearCache();"
30 "};" 29 "};"
31 "chrome.benchmarking.closeConnections = function() {" 30 "chrome.benchmarking.closeConnections = function() {"
32 " native function CloseConnections();" 31 " native function CloseConnections();"
33 " CloseConnections();" 32 " CloseConnections();"
34 "};" 33 "};"
35 "chrome.benchmarking.counter = function(name) {" 34 "chrome.benchmarking.counter = function(name) {"
36 " native function GetCounter();" 35 " native function GetCounter();"
37 " return GetCounter(name);" 36 " return GetCounter(name);"
38 "};" 37 "};"
39 "chrome.benchmarking.isSingleProcess = function() {"
40 " native function IsSingleProcess();"
41 " return IsSingleProcess();"
42 "};"
43 ) {} 38 ) {}
44 39
45 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 40 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
46 v8::Handle<v8::String> name) { 41 v8::Handle<v8::String> name) {
47 if (name->Equals(v8::String::New("CloseConnections"))) { 42 if (name->Equals(v8::String::New("CloseConnections"))) {
48 return v8::FunctionTemplate::New(CloseConnections); 43 return v8::FunctionTemplate::New(CloseConnections);
49 } else if (name->Equals(v8::String::New("ClearCache"))) { 44 } else if (name->Equals(v8::String::New("ClearCache"))) {
50 return v8::FunctionTemplate::New(ClearCache); 45 return v8::FunctionTemplate::New(ClearCache);
51 } else if (name->Equals(v8::String::New("GetCounter"))) { 46 } else if (name->Equals(v8::String::New("GetCounter"))) {
52 return v8::FunctionTemplate::New(GetCounter); 47 return v8::FunctionTemplate::New(GetCounter);
53 } else if (name->Equals(v8::String::New("IsSingleProcess"))) {
54 return v8::FunctionTemplate::New(IsSingleProcess);
55 } 48 }
56 return v8::Handle<v8::FunctionTemplate>(); 49 return v8::Handle<v8::FunctionTemplate>();
57 } 50 }
58 51
59 static v8::Handle<v8::Value> CloseConnections(const v8::Arguments& args) { 52 static v8::Handle<v8::Value> CloseConnections(const v8::Arguments& args) {
60 webkit_glue::CloseCurrentConnections(); 53 webkit_glue::CloseCurrentConnections();
61 return v8::Undefined(); 54 return v8::Undefined();
62 } 55 }
63 56
64 static v8::Handle<v8::Value> ClearCache(const v8::Arguments& args) { 57 static v8::Handle<v8::Value> ClearCache(const v8::Arguments& args) {
65 webkit_glue::ClearCache(); 58 webkit_glue::ClearCache();
66 WebCache::clear(); 59 WebCache::clear();
67 return v8::Undefined(); 60 return v8::Undefined();
68 } 61 }
69 62
70 static v8::Handle<v8::Value> GetCounter(const v8::Arguments& args) { 63 static v8::Handle<v8::Value> GetCounter(const v8::Arguments& args) {
71 if (!args.Length() || !args[0]->IsString() || !StatsTable::current()) 64 if (!args.Length() || !args[0]->IsString() || !StatsTable::current())
72 return v8::Undefined(); 65 return v8::Undefined();
73 66
74 // Extract the name argument 67 // Extract the name argument
75 char name[256]; 68 char name[256];
76 name[0] = 'c'; 69 name[0] = 'c';
77 name[1] = ':'; 70 name[1] = ':';
78 args[0]->ToString()->WriteAscii(&name[2], 0, sizeof(name) - 3); 71 args[0]->ToString()->WriteAscii(&name[2], 0, sizeof(name) - 3);
79 72
80 int counter = StatsTable::current()->GetCounterValue(name); 73 int counter = StatsTable::current()->GetCounterValue(name);
81 return v8::Integer::New(counter); 74 return v8::Integer::New(counter);
82 } 75 }
83
84 static v8::Handle<v8::Value> IsSingleProcess(const v8::Arguments& args) {
85 return v8::Boolean::New(webkit_glue::IsSingleProcess());
86 }
87 }; 76 };
88 77
89 v8::Extension* BenchmarkingExtension::Get() { 78 v8::Extension* BenchmarkingExtension::Get() {
90 return new BenchmarkingWrapper(); 79 return new BenchmarkingWrapper();
91 } 80 }
92 81
93 } // namespace extensions_v8 82 } // 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