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_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) { | 89 static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) { |
90 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 90 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
91 BrowserThread::PostTask( | 91 BrowserThread::PostTask( |
92 BrowserThread::IO, FROM_HERE, | 92 BrowserThread::IO, FROM_HERE, |
93 base::Bind(&IndexedDBBrowserTest::SetTempQuota, bytes, qm)); | 93 base::Bind(&IndexedDBBrowserTest::SetTempQuota, bytes, qm)); |
94 return; | 94 return; |
95 } | 95 } |
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
97 qm->SetTemporaryGlobalOverrideQuota(bytes, quota::QuotaCallback()); | 97 qm->SetTemporaryGlobalOverrideQuota(bytes, quota::QuotaCallback()); |
98 // Don't return until the quota has been set. | 98 // Don't return until the quota has been set. |
99 scoped_refptr<base::ThreadTestHelper> helper( | 99 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( |
100 new base::ThreadTestHelper( | 100 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get())); |
101 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); | |
102 ASSERT_TRUE(helper->Run()); | 101 ASSERT_TRUE(helper->Run()); |
103 } | 102 } |
104 | 103 |
105 virtual int64 RequestDiskUsage() { | 104 virtual int64 RequestDiskUsage() { |
106 BrowserThread::PostTaskAndReplyWithResult( | 105 BrowserThread::PostTaskAndReplyWithResult( |
107 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, | 106 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
108 base::Bind(&IndexedDBContext::GetOriginDiskUsage, GetContext(), | 107 base::Bind(&IndexedDBContext::GetOriginDiskUsage, GetContext(), |
109 GURL("file:///")), base::Bind( | 108 GURL("file:///")), base::Bind( |
110 &IndexedDBBrowserTest::DidGetDiskUsage, this)); | 109 &IndexedDBBrowserTest::DidGetDiskUsage, this)); |
111 scoped_refptr<base::ThreadTestHelper> helper( | 110 scoped_refptr<base::ThreadTestHelper> helper( |
112 new base::ThreadTestHelper(BrowserThread::GetMessageLoopProxyForThread( | 111 new base::ThreadTestHelper(BrowserThread::GetMessageLoopProxyForThread( |
113 BrowserThread::WEBKIT_DEPRECATED))); | 112 BrowserThread::WEBKIT_DEPRECATED).get())); |
114 EXPECT_TRUE(helper->Run()); | 113 EXPECT_TRUE(helper->Run()); |
115 // Wait for DidGetDiskUsage to be called. | 114 // Wait for DidGetDiskUsage to be called. |
116 base::MessageLoop::current()->RunUntilIdle(); | 115 base::MessageLoop::current()->RunUntilIdle(); |
117 return disk_usage_; | 116 return disk_usage_; |
118 } | 117 } |
119 private: | 118 private: |
120 virtual void DidGetDiskUsage(int64 bytes) { | 119 virtual void DidGetDiskUsage(int64 bytes) { |
121 EXPECT_GT(bytes, 0); | 120 EXPECT_GT(bytes, 0); |
122 disk_usage_ = bytes; | 121 disk_usage_ = bytes; |
123 } | 122 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { | 248 class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { |
250 public: | 249 public: |
251 virtual void SetUpOnMainThread() OVERRIDE { | 250 virtual void SetUpOnMainThread() OVERRIDE { |
252 scoped_refptr<IndexedDBContext> context = GetContext(); | 251 scoped_refptr<IndexedDBContext> context = GetContext(); |
253 BrowserThread::PostTask( | 252 BrowserThread::PostTask( |
254 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, | 253 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
255 base::Bind(&CopyLevelDBToProfile, shell(), context, | 254 base::Bind(&CopyLevelDBToProfile, shell(), context, |
256 EnclosingLevelDBDir())); | 255 EnclosingLevelDBDir())); |
257 scoped_refptr<base::ThreadTestHelper> helper( | 256 scoped_refptr<base::ThreadTestHelper> helper( |
258 new base::ThreadTestHelper(BrowserThread::GetMessageLoopProxyForThread( | 257 new base::ThreadTestHelper(BrowserThread::GetMessageLoopProxyForThread( |
259 BrowserThread::WEBKIT_DEPRECATED))); | 258 BrowserThread::WEBKIT_DEPRECATED).get())); |
260 ASSERT_TRUE(helper->Run()); | 259 ASSERT_TRUE(helper->Run()); |
261 } | 260 } |
262 | 261 |
263 virtual std::string EnclosingLevelDBDir() = 0; | 262 virtual std::string EnclosingLevelDBDir() = 0; |
264 | 263 |
265 }; | 264 }; |
266 | 265 |
267 class IndexedDBBrowserTestWithVersion0Schema : public | 266 class IndexedDBBrowserTestWithVersion0Schema : public |
268 IndexedDBBrowserTestWithPreexistingLevelDB { | 267 IndexedDBBrowserTestWithPreexistingLevelDB { |
269 virtual std::string EnclosingLevelDBDir() OVERRIDE { | 268 virtual std::string EnclosingLevelDBDir() OVERRIDE { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); | 413 TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); |
415 | 414 |
416 base::KillProcess( | 415 base::KillProcess( |
417 shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); | 416 shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); |
418 shell()->Close(); | 417 shell()->Close(); |
419 | 418 |
420 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 419 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
421 } | 420 } |
422 | 421 |
423 } // namespace content | 422 } // namespace content |
OLD | NEW |