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

Side by Side Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 12286020: Replace FilePath with base::FilePath. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/gpu/gpu_benchmarking_extension.h" 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 void InitSkGraphics() { 42 void InitSkGraphics() {
43 static bool init = false; 43 static bool init = false;
44 if (!init) { 44 if (!init) {
45 SkGraphics::Init(); 45 SkGraphics::Init();
46 init = true; 46 init = true;
47 } 47 }
48 } 48 }
49 49
50 class SkPictureRecorder : public WebViewBenchmarkSupport::PaintClient { 50 class SkPictureRecorder : public WebViewBenchmarkSupport::PaintClient {
51 public: 51 public:
52 explicit SkPictureRecorder(const FilePath& dirpath) 52 explicit SkPictureRecorder(const base::FilePath& dirpath)
53 : dirpath_(dirpath), 53 : dirpath_(dirpath),
54 layer_id_(0) { 54 layer_id_(0) {
55 // Let skia register known effect subclasses. This basically enables 55 // Let skia register known effect subclasses. This basically enables
56 // reflection on those subclasses required for picture serialization. 56 // reflection on those subclasses required for picture serialization.
57 InitSkGraphics(); 57 InitSkGraphics();
58 } 58 }
59 59
60 virtual WebCanvas* willPaint(const WebSize& size) { 60 virtual WebCanvas* willPaint(const WebSize& size) {
61 return picture_.beginRecording(size.width, size.height); 61 return picture_.beginRecording(size.width, size.height);
62 } 62 }
63 63
64 virtual void didPaint(WebCanvas* canvas) { 64 virtual void didPaint(WebCanvas* canvas) {
65 DCHECK(canvas == picture_.getRecordingCanvas()); 65 DCHECK(canvas == picture_.getRecordingCanvas());
66 picture_.endRecording(); 66 picture_.endRecording();
67 // Serialize picture to file. 67 // Serialize picture to file.
68 // TODO(alokp): Note that for this to work Chrome needs to be launched with 68 // TODO(alokp): Note that for this to work Chrome needs to be launched with
69 // --no-sandbox command-line flag. Get rid of this limitation. 69 // --no-sandbox command-line flag. Get rid of this limitation.
70 // CRBUG: 139640. 70 // CRBUG: 139640.
71 std::string filename = "layer_" + base::IntToString(layer_id_++) + ".skp"; 71 std::string filename = "layer_" + base::IntToString(layer_id_++) + ".skp";
72 std::string filepath = dirpath_.AppendASCII(filename).MaybeAsASCII(); 72 std::string filepath = dirpath_.AppendASCII(filename).MaybeAsASCII();
73 DCHECK(!filepath.empty()); 73 DCHECK(!filepath.empty());
74 SkFILEWStream file(filepath.c_str()); 74 SkFILEWStream file(filepath.c_str());
75 DCHECK(file.isValid()); 75 DCHECK(file.isValid());
76 picture_.serialize(&file); 76 picture_.serialize(&file);
77 } 77 }
78 78
79 private: 79 private:
80 FilePath dirpath_; 80 base::FilePath dirpath_;
81 int layer_id_; 81 int layer_id_;
82 SkPicture picture_; 82 SkPicture picture_;
83 }; 83 };
84 84
85 class RenderingStatsEnumerator : public cc::RenderingStats::Enumerator { 85 class RenderingStatsEnumerator : public cc::RenderingStats::Enumerator {
86 public: 86 public:
87 RenderingStatsEnumerator(v8::Handle<v8::Object> stats_object) 87 RenderingStatsEnumerator(v8::Handle<v8::Object> stats_object)
88 : stats_object(stats_object) { } 88 : stats_object(stats_object) { }
89 89
90 virtual void AddInt64(const char* name, int64 value) OVERRIDE { 90 virtual void AddInt64(const char* name, int64 value) OVERRIDE {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return v8::Undefined(); 213 return v8::Undefined();
214 214
215 WebView* web_view = web_frame->view(); 215 WebView* web_view = web_frame->view();
216 if (!web_view) 216 if (!web_view)
217 return v8::Undefined(); 217 return v8::Undefined();
218 218
219 WebViewBenchmarkSupport* benchmark_support = web_view->benchmarkSupport(); 219 WebViewBenchmarkSupport* benchmark_support = web_view->benchmarkSupport();
220 if (!benchmark_support) 220 if (!benchmark_support)
221 return v8::Undefined(); 221 return v8::Undefined();
222 222
223 FilePath dirpath(FilePath::StringType(*dirname, 223 base::FilePath dirpath(
224 *dirname + dirname.length())); 224 base::FilePath::StringType(*dirname, *dirname + dirname.length()));
225 if (!file_util::CreateDirectory(dirpath) || 225 if (!file_util::CreateDirectory(dirpath) ||
226 !file_util::PathIsWritable(dirpath)) { 226 !file_util::PathIsWritable(dirpath)) {
227 std::string msg("Path is not writable: "); 227 std::string msg("Path is not writable: ");
228 msg.append(dirpath.MaybeAsASCII()); 228 msg.append(dirpath.MaybeAsASCII());
229 return v8::ThrowException(v8::Exception::Error( 229 return v8::ThrowException(v8::Exception::Error(
230 v8::String::New(msg.c_str(), msg.length()))); 230 v8::String::New(msg.c_str(), msg.length())));
231 } 231 }
232 232
233 SkPictureRecorder recorder(dirpath); 233 SkPictureRecorder recorder(dirpath);
234 benchmark_support->paint(&recorder, 234 benchmark_support->paint(&recorder,
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 449
450 return v8::Undefined(); 450 return v8::Undefined();
451 } 451 }
452 }; 452 };
453 453
454 v8::Extension* GpuBenchmarkingExtension::Get() { 454 v8::Extension* GpuBenchmarkingExtension::Get() {
455 return new GpuBenchmarkingWrapper(); 455 return new GpuBenchmarkingWrapper();
456 } 456 }
457 457
458 } // namespace content 458 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_launcher.cc ('k') | content/renderer/hyphenator/hyphenator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698