OLD | NEW |
---|---|
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/cancelable_callback.h" | 5 #include "base/cancelable_callback.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 day, | 85 day, |
86 base::Bind(&CountingPolicyTest::CheckWrapper, | 86 base::Bind(&CountingPolicyTest::CheckWrapper, |
87 checker, | 87 checker, |
88 base::MessageLoop::current()->QuitClosure())); | 88 base::MessageLoop::current()->QuitClosure())); |
89 | 89 |
90 // Set up a timeout that will trigger after 5 seconds; if we haven't | 90 // Set up a timeout that will trigger after 5 seconds; if we haven't |
91 // received any results by then assume that the test is broken. | 91 // received any results by then assume that the test is broken. |
92 base::CancelableClosure timeout( | 92 base::CancelableClosure timeout( |
93 base::Bind(&CountingPolicyTest::TimeoutCallback)); | 93 base::Bind(&CountingPolicyTest::TimeoutCallback)); |
94 base::MessageLoop::current()->PostDelayedTask( | 94 base::MessageLoop::current()->PostDelayedTask( |
95 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(5)); | 95 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(5)); |
mvrable
2013/09/05 18:10:55
I would update this timeout as well to be consiste
| |
96 | 96 |
97 // Wait for results; either the checker or the timeout callbacks should | 97 // Wait for results; either the checker or the timeout callbacks should |
98 // cause the main loop to exit. | 98 // cause the main loop to exit. |
99 base::MessageLoop::current()->Run(); | 99 base::MessageLoop::current()->Run(); |
100 | 100 |
101 timeout.Cancel(); | 101 timeout.Cancel(); |
102 } | 102 } |
103 | 103 |
104 // A helper function to call ReadFilteredData on a policy object and wait for | 104 // A helper function to call ReadFilteredData on a policy object and wait for |
105 // the results to be processed. | 105 // the results to be processed. |
(...skipping 11 matching lines...) Expand all Loading... | |
117 policy->ReadFilteredData( | 117 policy->ReadFilteredData( |
118 extension_id, | 118 extension_id, |
119 type, | 119 type, |
120 api_name, | 120 api_name, |
121 page_url, | 121 page_url, |
122 arg_url, | 122 arg_url, |
123 base::Bind(&CountingPolicyTest::CheckWrapper, | 123 base::Bind(&CountingPolicyTest::CheckWrapper, |
124 checker, | 124 checker, |
125 base::MessageLoop::current()->QuitClosure())); | 125 base::MessageLoop::current()->QuitClosure())); |
126 | 126 |
127 // Set up a timeout that will trigger after 5 seconds; if we haven't | 127 // Set up a timeout that will trigger after 8 seconds; if we haven't |
128 // received any results by then assume that the test is broken. | 128 // received any results by then assume that the test is broken. |
129 base::CancelableClosure timeout( | 129 base::CancelableClosure timeout( |
130 base::Bind(&CountingPolicyTest::TimeoutCallback)); | 130 base::Bind(&CountingPolicyTest::TimeoutCallback)); |
131 base::MessageLoop::current()->PostDelayedTask( | 131 base::MessageLoop::current()->PostDelayedTask( |
132 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(5)); | 132 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(8)); |
133 | 133 |
134 // Wait for results; either the checker or the timeout callbacks should | 134 // Wait for results; either the checker or the timeout callbacks should |
135 // cause the main loop to exit. | 135 // cause the main loop to exit. |
136 base::MessageLoop::current()->Run(); | 136 base::MessageLoop::current()->Run(); |
137 | 137 |
138 timeout.Cancel(); | 138 timeout.Cancel(); |
139 } | 139 } |
140 | 140 |
141 // A helper function which verifies that the string_ids and url_ids tables in | 141 // A helper function which verifies that the string_ids and url_ids tables in |
142 // the database have the specified sizes. | 142 // the database have the specified sizes. |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 CountingPolicy* policy = new CountingPolicy(profile_.get()); | 791 CountingPolicy* policy = new CountingPolicy(profile_.get()); |
792 | 792 |
793 for (int i = 0; i < 305; i++) { | 793 for (int i = 0; i < 305; i++) { |
794 scoped_refptr<Action> action = | 794 scoped_refptr<Action> action = |
795 new Action("punky", | 795 new Action("punky", |
796 base::Time::Now(), | 796 base::Time::Now(), |
797 Action::ACTION_API_CALL, | 797 Action::ACTION_API_CALL, |
798 base::StringPrintf("apicall_%d", i)); | 798 base::StringPrintf("apicall_%d", i)); |
799 policy->ProcessAction(action); | 799 policy->ProcessAction(action); |
800 } | 800 } |
801 | |
801 policy->Flush(); | 802 policy->Flush(); |
803 WaitOnThread(BrowserThread::DB); | |
802 | 804 |
803 CheckReadFilteredData( | 805 CheckReadFilteredData( |
804 policy, | 806 policy, |
805 "punky", | 807 "punky", |
806 Action::ACTION_ANY, | 808 Action::ACTION_ANY, |
807 "", | 809 "", |
808 "", | 810 "", |
809 "", | 811 "", |
810 base::Bind( | 812 base::Bind( |
811 &CountingPolicyTest::RetrieveActions_FetchFilteredActions300)); | 813 &CountingPolicyTest::RetrieveActions_FetchFilteredActions300)); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
923 | 925 |
924 CheckReadData( | 926 CheckReadData( |
925 policy, | 927 policy, |
926 "punky", | 928 "punky", |
927 0, | 929 0, |
928 base::Bind(&CountingPolicyTest::SomeURLsRemoved)); | 930 base::Bind(&CountingPolicyTest::SomeURLsRemoved)); |
929 policy->Close(); | 931 policy->Close(); |
930 } | 932 } |
931 | 933 |
932 } // namespace extensions | 934 } // namespace extensions |
OLD | NEW |