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


CrOS-Libchrome-Original-Commit: ea1a3f60aa4527939af680eda25c7697901f643c
diff --git a/base/base.gyp b/base/base.gyp
index c1448d8..4102004 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -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',
diff --git a/base/base.gypi b/base/base.gypi
index 6f2a53a..c73ade5 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -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',
diff --git a/base/file_util_proxy_unittest.cc b/base/file_util_proxy_unittest.cc
index 42856c4..ed54037 100644
--- a/base/file_util_proxy_unittest.cc
+++ b/base/file_util_proxy_unittest.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"
 
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 8bee6a8..452ee82 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -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 @@
     ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
   }
 
-  ScopedTempDir temp_dir_;
+  base::ScopedTempDir temp_dir_;
 };
 
 // Collects all the results from the given file enumerator, and provides an
diff --git a/base/files/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc
index 94439b1..6405823 100644
--- a/base/files/file_path_watcher_browsertest.cc
+++ b/base/files/file_path_watcher_browsertest.cc
@@ -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"
diff --git a/base/files/important_file_writer_unittest.cc b/base/files/important_file_writer_unittest.cc
index a284d38..3bd3016 100644
--- a/base/files/important_file_writer_unittest.cc
+++ b/base/files/important_file_writer_unittest.cc
@@ -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"
diff --git a/base/scoped_temp_dir.cc b/base/files/scoped_temp_dir.cc
similarity index 95%
rename from base/scoped_temp_dir.cc
rename to base/files/scoped_temp_dir.cc
index 9f4bcf4..509f808 100644
--- a/base/scoped_temp_dir.cc
+++ b/base/files/scoped_temp_dir.cc
@@ -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 @@
 bool ScopedTempDir::IsValid() const {
   return !path_.empty() && file_util::DirectoryExists(path_);
 }
+
+}  // namespace base
diff --git a/base/scoped_temp_dir.h b/base/files/scoped_temp_dir.h
similarity index 92%
rename from base/scoped_temp_dir.h
rename to base/files/scoped_temp_dir.h
index 94acefc..641e7ef 100644
--- a/base/scoped_temp_dir.h
+++ b/base/files/scoped_temp_dir.h
@@ -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 @@
   DISALLOW_COPY_AND_ASSIGN(ScopedTempDir);
 };
 
-#endif  // BASE_SCOPED_TEMP_DIR_H_
+}  // namespace base
+
+#endif  // BASE_FILES_SCOPED_TEMP_DIR_H_
diff --git a/base/scoped_temp_dir_unittest.cc b/base/files/scoped_temp_dir_unittest.cc
similarity index 97%
rename from base/scoped_temp_dir_unittest.cc
rename to base/files/scoped_temp_dir_unittest.cc
index eddea83..8497ac6 100644
--- a/base/scoped_temp_dir_unittest.cc
+++ b/base/files/scoped_temp_dir_unittest.cc
@@ -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 @@
   EXPECT_TRUE(dir.Delete());
 }
 #endif  // defined(OS_WIN)
+
+}  // namespace base
diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc
index 89e3e4d..dc103dd 100644
--- a/base/json/json_value_serializer_unittest.cc
+++ b/base/json/json_value_serializer_unittest.cc
@@ -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"
diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc
index 5b282c6..0b96c12 100644
--- a/base/path_service_unittest.cc
+++ b/base/path_service_unittest.cc
@@ -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 @@
 // 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 @@
 // 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 @@
   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;
diff --git a/base/platform_file_unittest.cc b/base/platform_file_unittest.cc
index 671deb0..3b07c98 100644
--- a/base/platform_file_unittest.cc
+++ b/base/platform_file_unittest.cc
@@ -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 @@
 } // 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, 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, 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, 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 @@
 
 // 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"),
diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc
index 5258660..c596a6b 100644
--- a/base/prefs/json_pref_store_unittest.cc
+++ b/base/prefs/json_pref_store_unittest.cc
@@ -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 @@
   }
 
   // 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.
diff --git a/base/test/scoped_path_override.h b/base/test/scoped_path_override.h
index cf5c810..3ac441c 100644
--- a/base/test/scoped_path_override.h
+++ b/base/test/scoped_path_override.h
@@ -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;