| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, | 188 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, |
| 189 DatabaseCallbacksTest) { | 189 DatabaseCallbacksTest) { |
| 190 SimpleTest(GetTestUrl("indexeddb", "database_callbacks_first.html")); | 190 SimpleTest(GetTestUrl("indexeddb", "database_callbacks_first.html")); |
| 191 } | 191 } |
| 192 | 192 |
| 193 class IndexedDBBrowserTestWithVersion0Schema : public IndexedDBBrowserTest { | 193 class IndexedDBBrowserTestWithVersion0Schema : public IndexedDBBrowserTest { |
| 194 public: | 194 public: |
| 195 virtual void SetUpOnMainThread() { | 195 virtual void SetUpOnMainThread() { |
| 196 scoped_refptr<IndexedDBContext> context = |
| 197 BrowserContext::GetIndexedDBContext( |
| 198 shell()->web_contents()->GetBrowserContext()); |
| 196 BrowserThread::PostTask( | 199 BrowserThread::PostTask( |
| 197 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, | 200 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
| 198 base::Bind( | 201 base::Bind( |
| 199 &IndexedDBBrowserTestWithVersion0Schema::CopyLevelDBToProfile, | 202 &IndexedDBBrowserTestWithVersion0Schema::CopyLevelDBToProfile, |
| 200 shell())); | 203 shell(), |
| 204 context)); |
| 201 scoped_refptr<base::ThreadTestHelper> helper( | 205 scoped_refptr<base::ThreadTestHelper> helper( |
| 202 new base::ThreadTestHelper(BrowserThread::GetMessageLoopProxyForThread( | 206 new base::ThreadTestHelper(BrowserThread::GetMessageLoopProxyForThread( |
| 203 BrowserThread::WEBKIT_DEPRECATED))); | 207 BrowserThread::WEBKIT_DEPRECATED))); |
| 204 ASSERT_TRUE(helper->Run()); | 208 ASSERT_TRUE(helper->Run()); |
| 205 } | 209 } |
| 206 static void CopyLevelDBToProfile(Shell* shell) { | 210 static void CopyLevelDBToProfile(Shell* shell, |
| 211 scoped_refptr<IndexedDBContext> context) { |
| 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 208 FilePath leveldb_dir(FILE_PATH_LITERAL("file__0.indexeddb.leveldb")); | 213 FilePath leveldb_dir(FILE_PATH_LITERAL("file__0.indexeddb.leveldb")); |
| 209 FilePath test_data_dir = | 214 FilePath test_data_dir = |
| 210 GetTestFilePath("indexeddb", "migration_from_0").Append(leveldb_dir); | 215 GetTestFilePath("indexeddb", "migration_from_0").Append(leveldb_dir); |
| 211 IndexedDBContext* context = BrowserContext::GetIndexedDBContext( | |
| 212 shell->web_contents()->GetBrowserContext()); | |
| 213 IndexedDBContextImpl* context_impl = | 216 IndexedDBContextImpl* context_impl = |
| 214 static_cast<IndexedDBContextImpl*>(context); | 217 static_cast<IndexedDBContextImpl*>(context.get()); |
| 215 FilePath dest = context_impl->data_path().Append(leveldb_dir); | 218 FilePath dest = context_impl->data_path().Append(leveldb_dir); |
| 216 // If we don't create the destination directory first, the contents of the | 219 // If we don't create the destination directory first, the contents of the |
| 217 // leveldb directory are copied directly into profile/IndexedDB instead of | 220 // leveldb directory are copied directly into profile/IndexedDB instead of |
| 218 // profile/IndexedDB/file__0.xxx/ | 221 // profile/IndexedDB/file__0.xxx/ |
| 219 ASSERT_TRUE(file_util::CreateDirectory(dest)); | 222 ASSERT_TRUE(file_util::CreateDirectory(dest)); |
| 220 const bool kRecursive = true; | 223 const bool kRecursive = true; |
| 221 ASSERT_TRUE(file_util::CopyDirectory(test_data_dir, | 224 ASSERT_TRUE(file_util::CopyDirectory(test_data_dir, |
| 222 context_impl->data_path(), | 225 context_impl->data_path(), |
| 223 kRecursive)); | 226 kRecursive)); |
| 224 } | 227 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); | 277 TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); |
| 275 | 278 |
| 276 base::KillProcess( | 279 base::KillProcess( |
| 277 shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); | 280 shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); |
| 278 shell()->Close(); | 281 shell()->Close(); |
| 279 | 282 |
| 280 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 283 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 281 } | 284 } |
| 282 | 285 |
| 283 } // namespace content | 286 } // namespace content |
| OLD | NEW |