Skip to content

Commit

Permalink
Move scoped_temp_dir from base to base/files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
brettw@chromium.org committed Nov 16, 2012
1 parent a628d19 commit ea1a3f6
Show file tree
Hide file tree
Showing 322 changed files with 826 additions and 809 deletions.
2 changes: 1 addition & 1 deletion base/base.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions base/base.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion base/file_util_proxy_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions base/file_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/files/file_path_watcher_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion base/files/important_file_writer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion base/scoped_temp_dir.cc → base/files/scoped_temp_dir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}

Expand Down Expand Up @@ -80,3 +82,5 @@ FilePath ScopedTempDir::Take() {
bool ScopedTempDir::IsValid() const {
return !path_.empty() && file_util::DirectoryExists(path_);
}

} // namespace base
10 changes: 7 additions & 3 deletions base/scoped_temp_dir.h → base/files/scoped_temp_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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_
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -111,3 +113,5 @@ TEST(ScopedTempDir, LockedTempDir) {
EXPECT_TRUE(dir.Delete());
}
#endif // defined(OS_WIN)

} // namespace base
2 changes: 1 addition & 1 deletion base/json/json_value_serializer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion base/mac/mac_util_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions base/path_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions base/platform_file_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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");

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions base/prefs/json_pref_store_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion base/test/scoped_path_override.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions base/win/event_trace_consumer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -356,7 +356,7 @@ class EtwTraceConsumerDataTest: public EtwTraceConsumerBaseTest {
}

EventQueue events_;
ScopedTempDir temp_dir_;
base::ScopedTempDir temp_dir_;
FilePath temp_file_;
};

Expand Down
4 changes: 2 additions & 2 deletions base/win/event_trace_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions base/win/shortcut_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_;
Expand Down
Loading

0 comments on commit ea1a3f6

Please sign in to comment.