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

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

Issue 119191: Add an extension to expose some primitives to JS for doing ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « webkit/extensions/v8/benchmarking_extension.h ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "Cache.h"
7 #include "webkit/extensions/v8/benchmarking_extension.h"
8 #include "webkit/glue/webkit_glue.h"
9
10 namespace extensions_v8 {
11
12 const char* kBenchmarkingExtensionName = "v8/Benchmarking";
13
14 class BenchmarkingWrapper : public v8::Extension {
15 public:
16 BenchmarkingWrapper() :
17 v8::Extension(kBenchmarkingExtensionName,
18 "if (typeof(chromium) == 'undefined') {"
19 " chromium = {};"
20 "};"
21 "if (typeof(chromium.benchmarking) == 'undefined') {"
22 " chromium.benchmarking = {};"
23 "};"
24 "chromium.benchmarking.clearCache = function() {"
25 " native function ClearCache();"
26 " ClearCache();"
27 "};"
28 "chromium.benchmarking.closeConnections = function() {"
29 " native function CloseConnections();"
30 " CloseConnections();"
31 "};") {}
32
33 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
34 v8::Handle<v8::String> name) {
35 if (name->Equals(v8::String::New("CloseConnections"))) {
36 return v8::FunctionTemplate::New(CloseConnections);
37 } else if (name->Equals(v8::String::New("ClearCache"))) {
38 return v8::FunctionTemplate::New(ClearCache);
39 }
40 return v8::Handle<v8::FunctionTemplate>();
41 }
42
43 static v8::Handle<v8::Value> CloseConnections(const v8::Arguments& args) {
44 webkit_glue::CloseIdleConnections();
45 return v8::Undefined();
46 }
47
48 static v8::Handle<v8::Value> ClearCache(const v8::Arguments& args) {
49 webkit_glue::SetCacheMode(false); // XXXMB - should be enable/disable?
50
51 // Disabling and re-enabling the cache forces it to flush.
52 WebCore::cache()->setDisabled(true);
53 WebCore::cache()->setDisabled(false);
54 return v8::Undefined();
55 }
56 };
57
58 v8::Extension* BenchmarkingExtension::Get() {
59 return new BenchmarkingWrapper();
60 }
61
62 } // namespace extensions_v8
OLDNEW
« no previous file with comments | « webkit/extensions/v8/benchmarking_extension.h ('k') | webkit/glue/webkit_glue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698