summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-01 04:31:22 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-01 04:31:22 +0000
commit4f09393e0d9f357a271353b727246864378fdf17 (patch)
treec3b561d3384c9287cb11f545fa6adcae9b8d5a55
parente0291ec704fd21a4e99e99c60766c768f58ebcb3 (diff)
downloadchromium_src-4f09393e0d9f357a271353b727246864378fdf17.zip
chromium_src-4f09393e0d9f357a271353b727246864378fdf17.tar.gz
chromium_src-4f09393e0d9f357a271353b727246864378fdf17.tar.bz2
Deprecate wstring version of PathService::Get() in webkit.
Review URL: http://codereview.chromium.org/99266 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15032 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/event_recorder.cc4
-rw-r--r--base/event_recorder.h6
-rw-r--r--base/event_recorder_stubs.cc4
-rw-r--r--chrome/browser/browser_init.cc7
-rw-r--r--webkit/tools/test_shell/image_decoder_unittest.cc5
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc8
-rw-r--r--webkit/tools/test_shell/node_leak_test.cc10
-rwxr-xr-xwebkit/tools/test_shell/test_shell.cc19
-rw-r--r--webkit/tools/test_shell/test_shell_main.cc32
9 files changed, 53 insertions, 42 deletions
diff --git a/base/event_recorder.cc b/base/event_recorder.cc
index 3bcd0e26..92128af 100644
--- a/base/event_recorder.cc
+++ b/base/event_recorder.cc
@@ -42,7 +42,7 @@ EventRecorder::~EventRecorder() {
DCHECK(!is_recording_ && !is_playing_);
}
-bool EventRecorder::StartRecording(const std::wstring& filename) {
+bool EventRecorder::StartRecording(const FilePath& filename) {
if (journal_hook_ != NULL)
return false;
if (is_recording_ || is_playing_)
@@ -93,7 +93,7 @@ void EventRecorder::StopRecording() {
}
}
-bool EventRecorder::StartPlayback(const std::wstring& filename) {
+bool EventRecorder::StartPlayback(const FilePath& filename) {
if (journal_hook_ != NULL)
return false;
if (is_recording_ || is_playing_)
diff --git a/base/event_recorder.h b/base/event_recorder.h
index 43278c6..29ed350 100644
--- a/base/event_recorder.h
+++ b/base/event_recorder.h
@@ -11,6 +11,8 @@
#endif
#include "base/basictypes.h"
+class FilePath;
+
namespace base {
// A class for recording and playing back keyboard and mouse input events.
@@ -39,7 +41,7 @@ class EventRecorder {
// Starts recording events.
// Will clobber the file if it already exists.
// Returns true on success, or false if an error occurred.
- bool StartRecording(const std::wstring& filename);
+ bool StartRecording(const FilePath& filename);
// Stops recording.
void StopRecording();
@@ -49,7 +51,7 @@ class EventRecorder {
// Plays events previously recorded.
// Returns true on success, or false if an error occurred.
- bool StartPlayback(const std::wstring& filename);
+ bool StartPlayback(const FilePath& filename);
// Stops playback.
void StopPlayback();
diff --git a/base/event_recorder_stubs.cc b/base/event_recorder_stubs.cc
index 9499c75..91f2e07 100644
--- a/base/event_recorder_stubs.cc
+++ b/base/event_recorder_stubs.cc
@@ -11,14 +11,14 @@ namespace base {
EventRecorder* EventRecorder::current_; // Our singleton.
-bool EventRecorder::StartRecording(const std::wstring& filename) {
+bool EventRecorder::StartRecording(const FilePath& filename) {
return true;
}
void EventRecorder::StopRecording() {
}
-bool EventRecorder::StartPlayback(const std::wstring& filename) {
+bool EventRecorder::StartPlayback(const FilePath& filename) {
return false;
}
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 0bfc99e..88eae8b 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/event_recorder.h"
+#include "base/file_path.h"
#include "base/histogram.h"
#include "base/path_service.h"
#include "base/string_util.h"
@@ -97,10 +98,10 @@ void SetOverrideHomePage(const CommandLine& command_line,
PrefService* prefs) {
// If homepage is specified on the command line, canonify & store it.
if (command_line.HasSwitch(switches::kHomePage)) {
- std::wstring browser_directory;
+ FilePath browser_directory;
PathService::Get(base::DIR_CURRENT, &browser_directory);
std::wstring new_homepage = URLFixerUpper::FixupRelativeFile(
- browser_directory,
+ browser_directory.ToWStringHack(),
command_line.GetSwitchValue(switches::kHomePage));
prefs->transient()->SetString(prefs::kHomePage, new_homepage);
prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false);
@@ -250,7 +251,7 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
// If we're recording or playing back, startup the EventRecorder now
// unless otherwise specified.
if (!command_line_.HasSwitch(switches::kNoEvents)) {
- std::wstring script_path;
+ FilePath script_path;
PathService::Get(chrome::FILE_RECORDED_SCRIPT, &script_path);
bool record_mode = command_line_.HasSwitch(switches::kRecordMode);
diff --git a/webkit/tools/test_shell/image_decoder_unittest.cc b/webkit/tools/test_shell/image_decoder_unittest.cc
index 6db9de6..f4c9b72 100644
--- a/webkit/tools/test_shell/image_decoder_unittest.cc
+++ b/webkit/tools/test_shell/image_decoder_unittest.cc
@@ -6,6 +6,7 @@
#include "webkit/tools/test_shell/image_decoder_unittest.h"
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/md5.h"
#include "base/path_service.h"
@@ -78,7 +79,9 @@ void VerifyImage(WebCore::ImageDecoder* decoder,
#endif
void ImageDecoderTest::SetUp() {
- ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir_));
+ FilePath data_dir;
+ ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir));
+ data_dir_ = data_dir.ToWStringHack();
file_util::AppendToPath(&data_dir_, L"webkit");
file_util::AppendToPath(&data_dir_, L"data");
file_util::AppendToPath(&data_dir_, format_ + L"_decoder");
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index 70d6163..77192d5 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.cc
@@ -9,7 +9,7 @@
#include "webkit/tools/test_shell/layout_test_controller.h"
#include "base/basictypes.h"
-#include "base/file_util.h"
+#include "base/file_path.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/path_service.h"
@@ -596,10 +596,10 @@ void LayoutTestController::pathToLocalResource(
std::string url = args[0].ToString();
if (StartsWithASCII(url, "/tmp/", true)) {
// We want a temp file.
- std::wstring path;
+ FilePath path;
PathService::Get(base::DIR_TEMP, &path);
- file_util::AppendToPath(&path, UTF8ToWide(url.substr(5)));
- result->Set(WideToUTF8(path));
+ path = path.AppendASCII(url.substr(5));
+ result->Set(WideToUTF8(path.ToWStringHack()));
return;
}
diff --git a/webkit/tools/test_shell/node_leak_test.cc b/webkit/tools/test_shell/node_leak_test.cc
index 91ee6e8..dd87bef 100644
--- a/webkit/tools/test_shell/node_leak_test.cc
+++ b/webkit/tools/test_shell/node_leak_test.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "base/command_line.h"
-#include "base/file_util.h"
+#include "base/file_path.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "net/http/http_cache.h"
@@ -37,11 +37,11 @@ class NodeLeakTest : public TestShellTest {
js_flags += L" --expose-gc";
webkit_glue::SetJavaScriptFlags(js_flags);
- std::wstring cache_path =
- parsed_command_line.GetSwitchValue(test_shell::kCacheDir);
+ FilePath cache_path = FilePath::FromWStringHack(
+ parsed_command_line.GetSwitchValue(test_shell::kCacheDir));
if (cache_path.empty()) {
PathService::Get(base::DIR_EXE, &cache_path);
- file_util::AppendToPath(&cache_path, L"cache");
+ cache_path = cache_path.AppendASCII("cache");
}
if (parsed_command_line.HasSwitch(test_shell::kTestShellTimeOut)) {
@@ -58,7 +58,7 @@ class NodeLeakTest : public TestShellTest {
parsed_command_line.HasSwitch(test_shell::kPlaybackMode) ?
net::HttpCache::PLAYBACK : net::HttpCache::NORMAL;
SimpleResourceLoaderBridge::Init(
- new TestShellRequestContext(cache_path, mode, false));
+ new TestShellRequestContext(cache_path.ToWStringHack(), mode, false));
TestShellTest::SetUp();
}
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 3bef466..96a5ca5 100755
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -66,13 +66,12 @@ class URLRequestTestShellFileJob : public URLRequestFileJob {
static URLRequestJob* InspectorFactory(URLRequest* request,
const std::string& scheme) {
- std::wstring path;
+ FilePath path;
PathService::Get(base::DIR_EXE, &path);
- file_util::AppendToPath(&path, L"resources");
- file_util::AppendToPath(&path, L"inspector");
- file_util::AppendToPath(&path, UTF8ToWide(request->url().path()));
- return new URLRequestTestShellFileJob(request,
- FilePath::FromWStringHack(path));
+ path = path.AppendASCII("resources");
+ path = path.AppendASCII("inspector");
+ path = path.AppendASCII(request->url().path());
+ return new URLRequestTestShellFileJob(request, path);
}
private:
@@ -583,7 +582,11 @@ void AppendToLog(const char* file, int line, const char* msg) {
}
bool GetApplicationDirectory(std::wstring *path) {
- return PathService::Get(base::DIR_EXE, path);
+ bool r;
+ FilePath fp;
+ r = PathService::Get(base::DIR_EXE, &fp);
+ *path = fp.ToWStringHack();
+ return r;
}
GURL GetInspectorURL() {
@@ -595,7 +598,7 @@ std::string GetUIResourceProtocol() {
}
bool GetExeDirectory(std::wstring *path) {
- return PathService::Get(base::DIR_EXE, path);
+ return GetApplicationDirectory(path);
}
bool SpellCheckWord(const wchar_t* word, int word_len,
diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc
index 2e21b1b..6e8a385 100644
--- a/webkit/tools/test_shell/test_shell_main.cc
+++ b/webkit/tools/test_shell/test_shell_main.cc
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/event_recorder.h"
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/icu_util.h"
#include "base/memory_debug.h"
@@ -122,20 +123,21 @@ int main(int argc, char* argv[]) {
parsed_command_line.HasSwitch(test_shell::kEnableFileCookies))
net::CookieMonster::EnableFileScheme();
- std::wstring cache_path =
- parsed_command_line.GetSwitchValue(test_shell::kCacheDir);
+ FilePath cache_path = FilePath::FromWStringHack(
+ parsed_command_line.GetSwitchValue(test_shell::kCacheDir));
// If the cache_path is empty and it's layout_test_mode, leave it empty
// so we use an in-memory cache. This makes running multiple test_shells
// in parallel less flaky.
if (cache_path.empty() && !layout_test_mode) {
PathService::Get(base::DIR_EXE, &cache_path);
- file_util::AppendToPath(&cache_path, L"cache");
+ cache_path = cache_path.AppendASCII("cache");
}
// Initializing with a default context, which means no on-disk cookie DB,
// and no support for directory listings.
SimpleResourceLoaderBridge::Init(
- new TestShellRequestContext(cache_path, cache_mode, layout_test_mode));
+ new TestShellRequestContext(cache_path.ToWStringHack(),
+ cache_mode, layout_test_mode));
// Load ICU data tables
icu_util::Initialize();
@@ -169,20 +171,20 @@ int main(int argc, char* argv[]) {
}
// Treat the first loose value as the initial URL to open.
- std::wstring uri;
+ FilePath uri;
// Default to a homepage if we're interactive.
if (!layout_test_mode) {
PathService::Get(base::DIR_SOURCE_ROOT, &uri);
- file_util::AppendToPath(&uri, L"webkit");
- file_util::AppendToPath(&uri, L"data");
- file_util::AppendToPath(&uri, L"test_shell");
- file_util::AppendToPath(&uri, L"index.html");
+ uri = uri.AppendASCII("webkit");
+ uri = uri.AppendASCII("data");
+ uri = uri.AppendASCII("test_shell");
+ uri = uri.AppendASCII("index.html");
}
std::vector<std::wstring> loose_values = parsed_command_line.GetLooseValues();
if (loose_values.size() > 0)
- uri = loose_values[0];
+ uri = FilePath::FromWStringHack(loose_values[0]);
std::wstring js_flags =
parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags);
@@ -207,7 +209,7 @@ int main(int argc, char* argv[]) {
StatsTable::set_current(table);
TestShell* shell;
- if (TestShell::CreateNewWindow(uri, &shell)) {
+ if (TestShell::CreateNewWindow(uri.ToWStringHack(), &shell)) {
if (record_mode || playback_mode) {
platform.SetWindowPositionForRecording(shell);
WebKit::registerExtension(extensions_v8::PlaybackExtension::Get());
@@ -220,10 +222,10 @@ int main(int argc, char* argv[]) {
bool no_events = parsed_command_line.HasSwitch(test_shell::kNoEvents);
if ((record_mode || playback_mode) && !no_events) {
- std::wstring script_path = cache_path;
+ FilePath script_path = cache_path;
// Create the cache directory in case it doesn't exist.
file_util::CreateDirectory(cache_path);
- file_util::AppendToPath(&script_path, L"script.log");
+ script_path = script_path.AppendASCII("script.log");
if (record_mode)
base::EventRecorder::current()->StartRecording(script_path);
if (playback_mode)
@@ -259,7 +261,7 @@ int main(int argc, char* argv[]) {
params.dump_tree = false;
}
- if (uri.length() == 0) {
+ if (uri.empty()) {
// Watch stdin for URLs.
char filenameBuffer[kPathBufSize];
while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) {
@@ -293,7 +295,7 @@ int main(int argc, char* argv[]) {
} else {
// TODO(ojan): Provide a way for run-singly tests to pass
// in a hash and then set params.pixel_hash here.
- params.test_url = WideToUTF8(uri).c_str();
+ params.test_url = WideToUTF8(uri.ToWStringHack()).c_str();
TestShell::RunFileTest(params);
}