Commit ea1a3f60 authored by brettw@chromium.org's avatar brettw@chromium.org

Move scoped_temp_dir from base to base/files

Also add to base namespace.

BUG=

Review URL: https://codereview.chromium.org/11359217

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168281 0039d316-1c4b-4281-b951-d872f2087c98
parent a628d191
......@@ -437,6 +437,7 @@
'file_version_info_unittest.cc',
'files/dir_reader_posix_unittest.cc',
'files/important_file_writer_unittest.cc',
'files/scoped_temp_dir_unittest.cc',
'gmock_unittest.cc',
'guid_unittest.cc',
'hi_res_timer_manager_unittest.cc',
......@@ -504,7 +505,6 @@
'rand_util_unittest.cc',
'scoped_native_library_unittest.cc',
'scoped_observer.h',
'scoped_temp_dir_unittest.cc',
'sha1_unittest.cc',
'shared_memory_unittest.cc',
'string16_unittest.cc',
......
......@@ -153,6 +153,8 @@
'files/file_path_watcher_win.cc',
'files/important_file_writer.h',
'files/important_file_writer.cc',
'files/scoped_temp_dir.cc',
'files/scoped_temp_dir.h',
'float_util.h',
'format_macros.h',
'gtest_prod_util.h',
......@@ -346,8 +348,6 @@
'safe_strerror_posix.h',
'scoped_native_library.cc',
'scoped_native_library.h',
'scoped_temp_dir.cc',
'scoped_temp_dir.h',
'sequenced_task_runner.cc',
'sequenced_task_runner.h',
'sequenced_task_runner_helpers.h',
......@@ -593,7 +593,7 @@
'process_util_posix.cc',
'rand_util_posix.cc',
'scoped_native_library.cc',
'scoped_temp_dir.cc',
'files/scoped_temp_dir.cc',
'shared_memory_posix.cc',
'sys_info_posix.cc',
'threading/sequenced_worker_pool.cc',
......
......@@ -7,11 +7,11 @@
#include <map>
#include "base/bind.h"
#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "base/platform_file.h"
#include "base/scoped_temp_dir.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
......
......@@ -19,8 +19,8 @@
#include "base/base_paths.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/test/test_file_util.h"
#include "base/threading/platform_thread.h"
#include "base/utf_string_conversions.h"
......@@ -143,7 +143,7 @@ class FileUtilTest : public PlatformTest {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
}
ScopedTempDir temp_dir_;
base::ScopedTempDir temp_dir_;
};
// Collects all the results from the given file enumerator, and provides an
......
......@@ -19,10 +19,10 @@
#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/stl_util.h"
#include "base/stringprintf.h"
#include "base/synchronization/waitable_event.h"
......
......@@ -7,9 +7,9 @@
#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/scoped_temp_dir.h"
#include "base/threading/thread.h"
#include "base/time.h"
#include "testing/gtest/include/gtest/gtest.h"
......
......@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/scoped_temp_dir.h"
#include "base/files/scoped_temp_dir.h"
#include "base/file_util.h"
#include "base/logging.h"
namespace base {
ScopedTempDir::ScopedTempDir() {
}
......@@ -80,3 +82,5 @@ FilePath ScopedTempDir::Take() {
bool ScopedTempDir::IsValid() const {
return !path_.empty() && file_util::DirectoryExists(path_);
}
} // namespace base
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_SCOPED_TEMP_DIR_H_
#define BASE_SCOPED_TEMP_DIR_H_
#ifndef BASE_FILES_SCOPED_TEMP_DIR_H_
#define BASE_FILES_SCOPED_TEMP_DIR_H_
// An object representing a temporary / scratch directory that should be cleaned
// up (recursively) when this object goes out of scope. Note that since
......@@ -18,6 +18,8 @@
#include "base/base_export.h"
#include "base/file_path.h"
namespace base {
class BASE_EXPORT ScopedTempDir {
public:
// No directory is owned/created initially.
......@@ -55,4 +57,6 @@ class BASE_EXPORT ScopedTempDir {
DISALLOW_COPY_AND_ASSIGN(ScopedTempDir);
};
#endif // BASE_SCOPED_TEMP_DIR_H_
} // namespace base
#endif // BASE_FILES_SCOPED_TEMP_DIR_H_
......@@ -5,10 +5,12 @@
#include <string>
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/platform_file.h"
#include "base/scoped_temp_dir.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
TEST(ScopedTempDir, FullPath) {
FilePath test_path;
file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("scoped_temp_dir"),
......@@ -111,3 +113,5 @@ TEST(ScopedTempDir, LockedTempDir) {
EXPECT_TRUE(dir.Delete());
}
#endif // defined(OS_WIN)
} // namespace base
......@@ -5,11 +5,11 @@
#include <string>
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_file_value_serializer.h"
#include "base/json/json_reader.h"
#include "base/json/json_string_value_serializer.h"
#include "base/memory/scoped_ptr.h"
#include "base/scoped_temp_dir.h"
#include "base/string_util.h"
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
......
......@@ -8,10 +8,10 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/scoped_nsobject.h"
#include "base/scoped_temp_dir.h"
#include "base/sys_info.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
......
......@@ -5,13 +5,13 @@
#include "base/path_service.h"
#include "base/basictypes.h"
#include "base/file_util.h"
#include "base/file_path.h"
#include "base/scoped_temp_dir.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/string_util.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gtest/include/gtest/gtest-spi.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#if defined(OS_WIN)
......@@ -139,7 +139,7 @@ TEST_F(PathServiceTest, Get) {
// are supposed to do.
TEST_F(PathServiceTest, Override) {
int my_special_key = 666;
ScopedTempDir temp_dir;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
FilePath fake_cache_dir(temp_dir.path().AppendASCII("cache"));
// PathService::Override should always create the path provided if it doesn't
......@@ -162,7 +162,7 @@ TEST_F(PathServiceTest, Override) {
// Check if multiple overrides can co-exist.
TEST_F(PathServiceTest, OverrideMultiple) {
int my_special_key = 666;
ScopedTempDir temp_dir;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
FilePath fake_cache_dir1(temp_dir.path().AppendASCII("1"));
EXPECT_TRUE(PathService::Override(my_special_key, fake_cache_dir1));
......@@ -192,7 +192,7 @@ TEST_F(PathServiceTest, RemoveOverride) {
EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &original_user_data_dir));
EXPECT_FALSE(PathService::RemoveOverride(base::DIR_TEMP));
ScopedTempDir temp_dir;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
EXPECT_TRUE(PathService::Override(base::DIR_TEMP, temp_dir.path()));
FilePath new_user_data_dir;
......
......@@ -3,8 +3,8 @@
// found in the LICENSE file.
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/platform_file.h"
#include "base/scoped_temp_dir.h"
#include "base/time.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -26,7 +26,7 @@ int WriteFully(base::PlatformFile file, int64 offset,
} // namespace
TEST(PlatformFile, CreatePlatformFile) {
ScopedTempDir temp_dir;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
FilePath file_path = temp_dir.path().AppendASCII("create_file_1");
......@@ -95,7 +95,7 @@ TEST(PlatformFile, CreatePlatformFile) {
}
TEST(PlatformFile, DeleteOpenFile) {
ScopedTempDir temp_dir;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
FilePath file_path = temp_dir.path().AppendASCII("create_file_1");
......@@ -131,7 +131,7 @@ TEST(PlatformFile, DeleteOpenFile) {
}
TEST(PlatformFile, ReadWritePlatformFile) {
ScopedTempDir temp_dir;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
FilePath file_path = temp_dir.path().AppendASCII("read_write_file");
base::PlatformFile file = base::CreatePlatformFile(
......@@ -210,7 +210,7 @@ TEST(PlatformFile, ReadWritePlatformFile) {
}
TEST(PlatformFile, TruncatePlatformFile) {
ScopedTempDir temp_dir;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
FilePath file_path = temp_dir.path().AppendASCII("truncate_file");
base::PlatformFile file = base::CreatePlatformFile(
......@@ -261,7 +261,7 @@ TEST(PlatformFile, TruncatePlatformFile) {
// Flakily fails: http://crbug.com/86494
TEST(PlatformFile, DISABLED_TouchGetInfoPlatformFile) {
ScopedTempDir temp_dir;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::PlatformFile file = base::CreatePlatformFile(
temp_dir.path().AppendASCII("touch_get_info_file"),
......
......@@ -3,11 +3,11 @@
// found in the LICENSE file.
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/prefs/json_pref_store.h"
#include "base/scoped_temp_dir.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/threading/sequenced_worker_pool.h"
......@@ -45,7 +45,7 @@ class JsonPrefStoreTest : public testing::Test {
}
// The path to temporary directory used to contain the test operations.
ScopedTempDir temp_dir_;
base::ScopedTempDir temp_dir_;
// The path to the directory where the test data is stored.
FilePath data_dir_;
// A message loop that we can use as the file thread message loop.
......
......@@ -6,7 +6,7 @@
#define BASE_TEST_SCOPED_PATH_OVERRIDE_H_
#include "base/basictypes.h"
#include "base/scoped_temp_dir.h"
#include "base/files/scoped_temp_dir.h"
class FilePath;
......
......@@ -12,9 +12,9 @@
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/process.h"
#include "base/scoped_temp_dir.h"
#include "base/stringprintf.h"
#include "base/win/event_trace_controller.h"
#include "base/win/event_trace_provider.h"
......@@ -356,7 +356,7 @@ class EtwTraceConsumerDataTest: public EtwTraceConsumerBaseTest {
}
EventQueue events_;
ScopedTempDir temp_dir_;
base::ScopedTempDir temp_dir_;
FilePath temp_file_;
};
......
......@@ -9,9 +9,9 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/process.h"
#include "base/scoped_temp_dir.h"
#include "base/stringprintf.h"
#include "base/sys_info.h"
#include "base/win/event_trace_controller.h"
......@@ -161,7 +161,7 @@ TEST_F(EtwTraceControllerTest, StartRealTimeSession) {
}
TEST_F(EtwTraceControllerTest, StartFileSession) {
ScopedTempDir temp_dir;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
FilePath temp;
ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir.path(), &temp));
......
......@@ -8,7 +8,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/scoped_temp_dir.h"
#include "base/files/scoped_temp_dir.h"
#include "base/test/test_file_util.h"
#include "base/test/test_shortcut_win.h"
#include "base/win/scoped_com_initializer.h"
......@@ -62,8 +62,8 @@ class ShortcutTest : public testing::Test {
}
base::win::ScopedCOMInitializer com_initializer_;
ScopedTempDir temp_dir_;
ScopedTempDir temp_dir_2_;
base::ScopedTempDir temp_dir_;
base::ScopedTempDir temp_dir_2_;
// The link file to be created/updated in the shortcut tests below.
FilePath link_file_;
......
......@@ -5,10 +5,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/i18n/time_formatting.h"
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/string16.h"
#include "base/string_util.h"
#include "base/time.h"
......@@ -116,7 +116,7 @@ class BookmarkHTMLWriterTest : public testing::Test {
BookmarkEntryToString(entry));
}
ScopedTempDir temp_dir_;
base::ScopedTempDir temp_dir_;
FilePath path_;
};
......
......@@ -4,7 +4,7 @@
#include "base/bind.h"
#include "base/file_util.h"
#include "base/scoped_temp_dir.h"
#include "base/files/scoped_temp_dir.h"
#include "chrome/browser/character_encoding.h"
#include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/browser/prefs/pref_service.h"
......@@ -65,7 +65,7 @@ class BrowserEncodingTest : public InProcessBrowserTest {
base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true));
}
ScopedTempDir temp_dir_;
base::ScopedTempDir temp_dir_;
FilePath save_dir_;
FilePath temp_sub_resource_dir_;
};
......
......@@ -5,11 +5,11 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "base/bind.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/message_loop.h"
#include "base/scoped_temp_dir.h"
#include "base/message_loop_proxy.h"
#include "chrome/browser/browsing_data/browsing_data_quota_helper_impl.h"
#include "content/public/test/test_browser_thread.h"
#include "webkit/quota/mock_storage_client.h"
......@@ -119,7 +119,7 @@ class BrowsingDataQuotaHelperTest : public testing::Test {
content::TestBrowserThread io_thread_;
scoped_refptr<quota::QuotaManager> quota_manager_;
ScopedTempDir dir_;
base::ScopedTempDir dir_;
scoped_refptr<BrowsingDataQuotaHelper> helper_;
bool fetching_completed_;
......
......@@ -65,7 +65,7 @@ class BrowsingDataRemoverBrowserTest : public InProcessBrowserTest {
// Test BrowsingDataRemover for downloads.
IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverBrowserTest, Download) {
ScopedTempDir downloads_directory;
base::ScopedTempDir downloads_directory;
ASSERT_TRUE(downloads_directory.CreateUniqueTempDir());
browser()->profile()->GetPrefs()->SetFilePath(
prefs::kDownloadDefaultDirectory, downloads_directory.path());
......
......@@ -9,10 +9,10 @@
#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop.h"
#include "base/scoped_temp_dir.h"
#include "chrome/browser/chromeos/contacts/contact.pb.h"
#include "chrome/browser/chromeos/contacts/contact_test_util.h"
#include "content/public/browser/browser_thread.h"
......@@ -133,7 +133,7 @@ class ContactDatabaseTest : public testing::Test {
content::TestBrowserThread ui_thread_;
// Temporary directory where the database is saved.
ScopedTempDir temp_dir_;
base::ScopedTempDir temp_dir_;
// This class retains ownership of this object.
ContactDatabase* db_;
......
......@@ -5,15 +5,15 @@
#include <cert.h>
#include <pk11pub.h>
#include <vector>
#include <string>
#include <vector>
#include "base/at_exit.h"
#include "base/callback.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/cros/onc_network_parser.h"
......
......@@ -5,7 +5,7 @@
#include "chrome/browser/chromeos/drive/drive_cache_metadata.h"
#include "base/file_util.h"
#include "base/scoped_temp_dir.h"
#include "base/files/scoped_temp_dir.h"
#include "chrome/browser/chromeos/drive/drive.pb.h"
#include "chrome/browser/chromeos/drive/drive_file_system_util.h"
#include "chrome/browser/chromeos/drive/drive_test_util.h"
......@@ -128,7 +128,7 @@ class DriveCacheMetadataTest : public testing::Test {
}
}
ScopedTempDir temp_dir_;
base::ScopedTempDir temp_dir_;
scoped_ptr<DriveCacheMetadata> metadata_;
std::vector<FilePath> cache_paths_;
FilePath persistent_directory_;
......
......@@ -10,11 +10,11 @@
#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_file_value_serializer.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"