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

Side by Side Diff: chrome/browser/extensions/test_extension_dir.cc

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/extensions/test_extension_dir.h" 5 #include "chrome/browser/extensions/test_extension_dir.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "base/test/values_test_util.h" 10 #include "base/test/values_test_util.h"
(...skipping 14 matching lines...) Expand all
25 // TODO(kalman): Write some more convenient way to specify a manifest than 25 // TODO(kalman): Write some more convenient way to specify a manifest than
26 // via JSON, which requires awkwardly escaping all quotes. E.g. add a feature 26 // via JSON, which requires awkwardly escaping all quotes. E.g. add a feature
27 // to JSONReader that can parse '' literals rather than "". 27 // to JSONReader that can parse '' literals rather than "".
28 WriteFile(FILE_PATH_LITERAL("manifest.json"), manifest); 28 WriteFile(FILE_PATH_LITERAL("manifest.json"), manifest);
29 } 29 }
30 30
31 void TestExtensionDir::WriteFile(const base::FilePath::StringType& filename, 31 void TestExtensionDir::WriteFile(const base::FilePath::StringType& filename,
32 base::StringPiece contents) { 32 base::StringPiece contents) {
33 EXPECT_EQ( 33 EXPECT_EQ(
34 base::checked_cast<int>(contents.size()), 34 base::checked_cast<int>(contents.size()),
35 file_util::WriteFile( 35 base::WriteFile(
36 dir_.path().Append(filename), contents.data(), contents.size())); 36 dir_.path().Append(filename), contents.data(), contents.size()));
37 } 37 }
38 38
39 // This function packs the extension into a .crx, and returns the path to that 39 // This function packs the extension into a .crx, and returns the path to that
40 // .crx. Multiple calls to Pack() will produce extensions with the same ID. 40 // .crx. Multiple calls to Pack() will produce extensions with the same ID.
41 base::FilePath TestExtensionDir::Pack() { 41 base::FilePath TestExtensionDir::Pack() {
42 ExtensionCreator creator; 42 ExtensionCreator creator;
43 base::FilePath crx_path = 43 base::FilePath crx_path =
44 crx_dir_.path().Append(FILE_PATH_LITERAL("ext.crx")); 44 crx_dir_.path().Append(FILE_PATH_LITERAL("ext.crx"));
45 base::FilePath pem_path = 45 base::FilePath pem_path =
(...skipping 13 matching lines...) Expand all
59 return base::FilePath(); 59 return base::FilePath();
60 } 60 }
61 if (!base::PathExists(crx_path)) { 61 if (!base::PathExists(crx_path)) {
62 ADD_FAILURE() << crx_path.value() << " was not created."; 62 ADD_FAILURE() << crx_path.value() << " was not created.";
63 return base::FilePath(); 63 return base::FilePath();
64 } 64 }
65 return crx_path; 65 return crx_path;
66 } 66 }
67 67
68 } // namespace extensions 68 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/sandboxed_unpacker.cc ('k') | chrome/browser/extensions/updater/local_extension_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698