Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: content/browser/storage_partition_impl_unittest.cc

Issue 100453006: Move Touch to base namespace, remove SetLastModifiedTime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/message_loop/message_loop_proxy.h" 7 #include "base/message_loop/message_loop_proxy.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 base::FilePath storage_path = 203 base::FilePath storage_path =
204 profile_->GetPath().AppendASCII("Local Storage"); 204 profile_->GetPath().AppendASCII("Local Storage");
205 base::CreateDirectory(storage_path); 205 base::CreateDirectory(storage_path);
206 206
207 // Write some files. 207 // Write some files.
208 file_util::WriteFile(storage_path.Append(kDomStorageOrigin1), NULL, 0); 208 file_util::WriteFile(storage_path.Append(kDomStorageOrigin1), NULL, 0);
209 file_util::WriteFile(storage_path.Append(kDomStorageOrigin2), NULL, 0); 209 file_util::WriteFile(storage_path.Append(kDomStorageOrigin2), NULL, 0);
210 file_util::WriteFile(storage_path.Append(kDomStorageOrigin3), NULL, 0); 210 file_util::WriteFile(storage_path.Append(kDomStorageOrigin3), NULL, 0);
211 211
212 // Tweak their dates. 212 // Tweak their dates.
213 file_util::SetLastModifiedTime(storage_path.Append(kDomStorageOrigin1), 213 base::Time now = base::Time::Now();
viettrungluu 2013/12/04 21:09:23 (ditto)
214 base::Time::Now()); 214 base::TouchFile(storage_path.Append(kDomStorageOrigin1), now, now);
215 file_util::SetLastModifiedTime(storage_path.Append(kDomStorageOrigin2), 215
216 base::Time::Now() - base::TimeDelta::FromDays(1)); 216 base::Time one_day_ago = now - base::TimeDelta::FromDays(1);
217 file_util::SetLastModifiedTime(storage_path.Append(kDomStorageOrigin3), 217 base::TouchFile(storage_path.Append(kDomStorageOrigin2),
218 base::Time::Now() - base::TimeDelta::FromDays(60)); 218 one_day_ago, one_day_ago);
219
220 base::Time sixty_days_ago = now - base::TimeDelta::FromDays(60);
221 base::TouchFile(storage_path.Append(kDomStorageOrigin3),
222 sixty_days_ago, sixty_days_ago);
219 } 223 }
220 224
221 private: 225 private:
222 void GetLocalStorageUsage() { 226 void GetLocalStorageUsage() {
223 dom_storage_context_->GetLocalStorageUsage( 227 dom_storage_context_->GetLocalStorageUsage(
224 base::Bind(&RemoveLocalStorageTester::OnGotLocalStorageUsage, 228 base::Bind(&RemoveLocalStorageTester::OnGotLocalStorageUsage,
225 base::Unretained(this))); 229 base::Unretained(this)));
226 } 230 }
227 void OnGotLocalStorageUsage( 231 void OnGotLocalStorageUsage(
228 const std::vector<content::LocalStorageUsageInfo>& infos) { 232 const std::vector<content::LocalStorageUsageInfo>& infos) {
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 clear_cb.callback())); 960 clear_cb.callback()));
957 clear_cb.WaitForResult(); 961 clear_cb.WaitForResult();
958 962
959 // kOrigin1 and kOrigin2 do not have age more than a week. 963 // kOrigin1 and kOrigin2 do not have age more than a week.
960 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); 964 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1));
961 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); 965 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2));
962 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); 966 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3));
963 } 967 }
964 968
965 } // namespace content 969 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698