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

Unified Diff: content/test/test_content_client.cc

Issue 1210153008: Minor refactor to simplify code in content/test/test_content_client.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ios compile Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/test_content_client.cc
diff --git a/content/test/test_content_client.cc b/content/test/test_content_client.cc
index 70927fc3d872617e10f4549d55cf3edcaaad027f..16b8ad449d9aa38157015edff7bfb5bc83192f99 100644
--- a/content/test/test_content_client.cc
+++ b/content/test/test_content_client.cc
@@ -21,14 +21,13 @@ TestContentClient::TestContentClient()
// content_shell.pak is not built on iOS as it is not required.
#if !defined(OS_IOS)
base::FilePath content_shell_pack_path;
+ base::File pak_file;
+ base::MemoryMappedFile::Region pak_region;
+
#if defined(OS_ANDROID)
- base::MemoryMappedFile::Region region;
// Tests that don't yet use .isolate files require loading from within .apk.
- int fd = base::android::OpenApkAsset("assets/content_shell.pak", &region);
- if (fd >= 0) {
- data_pack_.LoadFromFileRegion(base::File(fd), region);
- return;
- }
+ pak_file = base::File(
+ base::android::OpenApkAsset("assets/content_shell.pak", &pak_region));
// on Android all pak files are inside the paks folder.
PathService::Get(base::DIR_ANDROID_APP_DATA, &content_shell_pack_path);
@@ -36,11 +35,16 @@ TestContentClient::TestContentClient()
FILE_PATH_LITERAL("paks"));
#else
PathService::Get(base::DIR_MODULE, &content_shell_pack_path);
-#endif
- content_shell_pack_path = content_shell_pack_path.Append(
- FILE_PATH_LITERAL("content_shell.pak"));
- data_pack_.LoadFromPath(content_shell_pack_path);
-#endif
+#endif // defined(OS_ANDROID)
+
+ if (pak_file.IsValid()) {
+ data_pack_.LoadFromFileRegion(pak_file.Pass(), pak_region);
+ } else {
+ content_shell_pack_path = content_shell_pack_path.Append(
+ FILE_PATH_LITERAL("content_shell.pak"));
+ data_pack_.LoadFromPath(content_shell_pack_path);
+ }
+#endif // !defined(OS_IOS)
}
TestContentClient::~TestContentClient() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698