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

Side by Side Diff: content/browser/gpu/gpu_pixel_browsertest.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/command_line.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG 53 // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG
54 // should have been encoded using |gfx::PNGCodec::Encode|. 54 // should have been encoded using |gfx::PNGCodec::Encode|.
55 bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap) { 55 bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap) {
56 DCHECK(bitmap); 56 DCHECK(bitmap);
57 base::FilePath abs_path(base::MakeAbsoluteFilePath(file_path)); 57 base::FilePath abs_path(base::MakeAbsoluteFilePath(file_path));
58 if (abs_path.empty()) 58 if (abs_path.empty())
59 return false; 59 return false;
60 60
61 std::string png_data; 61 std::string png_data;
62 return file_util::ReadFileToString(abs_path, &png_data) && 62 return base::ReadFileToString(abs_path, &png_data) &&
63 gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&png_data[0]), 63 gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&png_data[0]),
64 png_data.length(), 64 png_data.length(),
65 bitmap); 65 bitmap);
66 } 66 }
67 67
68 // Encodes a bitmap into a PNG and write to disk. Returns true on success. The 68 // Encodes a bitmap into a PNG and write to disk. Returns true on success. The
69 // parent directory does not have to exist. 69 // parent directory does not have to exist.
70 bool WritePNGFile(const SkBitmap& bitmap, const base::FilePath& file_path) { 70 bool WritePNGFile(const SkBitmap& bitmap, const base::FilePath& file_path) {
71 std::vector<unsigned char> png_data; 71 std::vector<unsigned char> png_data;
72 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &png_data) && 72 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &png_data) &&
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 559
560 gfx::Size container_size(400, 300); 560 gfx::Size container_size(400, 300);
561 base::FilePath url = 561 base::FilePath url =
562 test_data_dir().AppendASCII("pixel_browser_plugin.html"); 562 test_data_dir().AppendASCII("pixel_browser_plugin.html");
563 RunPixelTest(container_size, url, ref_img_revision_update, 563 RunPixelTest(container_size, url, ref_img_revision_update,
564 ref_pixels, ref_pixel_count); 564 ref_pixels, ref_pixel_count);
565 } 565 }
566 566
567 } // namespace content 567 } // namespace content
568 568
OLDNEW
« no previous file with comments | « content/browser/download/download_file_unittest.cc ('k') | content/browser/tracing/trace_subscriber_stdio_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698