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

Side by Side Diff: chrome/browser/net/sqlite_persistent_cookie_store_perftest.cc

Issue 11359217: Move scoped_temp_dir from base to base/files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 (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/files/scoped_temp_dir.h"
6 #include "base/message_loop.h" 7 #include "base/message_loop.h"
7 #include "base/perftimer.h" 8 #include "base/perftimer.h"
8 #include "base/scoped_temp_dir.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "base/test/thread_test_helper.h" 11 #include "base/test/thread_test_helper.h"
12 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" 12 #include "chrome/browser/net/sqlite_persistent_cookie_store.h"
13 #include "chrome/common/chrome_constants.h" 13 #include "chrome/common/chrome_constants.h"
14 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "net/cookies/canonical_cookie.h" 16 #include "net/cookies/canonical_cookie.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 store_ = new SQLitePersistentCookieStore( 79 store_ = new SQLitePersistentCookieStore(
80 temp_dir_.path().Append(chrome::kCookieFilename), false, NULL); 80 temp_dir_.path().Append(chrome::kCookieFilename), false, NULL);
81 } 81 }
82 82
83 protected: 83 protected:
84 content::TestBrowserThread db_thread_; 84 content::TestBrowserThread db_thread_;
85 content::TestBrowserThread io_thread_; 85 content::TestBrowserThread io_thread_;
86 base::WaitableEvent loaded_event_; 86 base::WaitableEvent loaded_event_;
87 base::WaitableEvent key_loaded_event_; 87 base::WaitableEvent key_loaded_event_;
88 std::vector<net::CanonicalCookie*> cookies_; 88 std::vector<net::CanonicalCookie*> cookies_;
89 ScopedTempDir temp_dir_; 89 base::ScopedTempDir temp_dir_;
90 scoped_refptr<SQLitePersistentCookieStore> store_; 90 scoped_refptr<SQLitePersistentCookieStore> store_;
91 }; 91 };
92 92
93 // Test the performance of priority load of cookies for a specfic domain key 93 // Test the performance of priority load of cookies for a specfic domain key
94 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadForKeyPerformance) { 94 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadForKeyPerformance) {
95 for (int domain_num = 0; domain_num < 3; ++domain_num) { 95 for (int domain_num = 0; domain_num < 3; ++domain_num) {
96 std::string domain_name(base::StringPrintf("domain_%d.com", domain_num)); 96 std::string domain_name(base::StringPrintf("domain_%d.com", domain_num));
97 PerfTimeLogger timer( 97 PerfTimeLogger timer(
98 ("Load cookies for the eTLD+1 " + domain_name).c_str()); 98 ("Load cookies for the eTLD+1 " + domain_name).c_str());
99 store_->LoadCookiesForKey(domain_name, 99 store_->LoadCookiesForKey(domain_name,
100 base::Bind(&SQLitePersistentCookieStorePerfTest::OnKeyLoaded, 100 base::Bind(&SQLitePersistentCookieStorePerfTest::OnKeyLoaded,
101 base::Unretained(this))); 101 base::Unretained(this)));
102 key_loaded_event_.Wait(); 102 key_loaded_event_.Wait();
103 timer.Done(); 103 timer.Done();
104 104
105 ASSERT_EQ(50U, cookies_.size()); 105 ASSERT_EQ(50U, cookies_.size());
106 } 106 }
107 } 107 }
108 108
109 // Test the performance of load 109 // Test the performance of load
110 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) { 110 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) {
111 PerfTimeLogger timer("Load all cookies"); 111 PerfTimeLogger timer("Load all cookies");
112 Load(); 112 Load();
113 timer.Done(); 113 timer.Done();
114 114
115 ASSERT_EQ(15000U, cookies_.size()); 115 ASSERT_EQ(15000U, cookies_.size());
116 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698