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/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 day, | 76 day, |
77 base::Bind(&FullStreamUIPolicyTest::CheckWrapper, | 77 base::Bind(&FullStreamUIPolicyTest::CheckWrapper, |
78 checker, | 78 checker, |
79 base::MessageLoop::current()->QuitClosure())); | 79 base::MessageLoop::current()->QuitClosure())); |
80 | 80 |
81 // Set up a timeout that will trigger after 5 seconds; if we haven't | 81 // Set up a timeout that will trigger after 5 seconds; if we haven't |
82 // received any results by then assume that the test is broken. | 82 // received any results by then assume that the test is broken. |
83 base::CancelableClosure timeout( | 83 base::CancelableClosure timeout( |
84 base::Bind(&FullStreamUIPolicyTest::TimeoutCallback)); | 84 base::Bind(&FullStreamUIPolicyTest::TimeoutCallback)); |
85 base::MessageLoop::current()->PostDelayedTask( | 85 base::MessageLoop::current()->PostDelayedTask( |
86 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(5)); | 86 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(8)); |
87 | 87 |
88 // Wait for results; either the checker or the timeout callbacks should | 88 // Wait for results; either the checker or the timeout callbacks should |
89 // cause the main loop to exit. | 89 // cause the main loop to exit. |
90 base::MessageLoop::current()->Run(); | 90 base::MessageLoop::current()->Run(); |
91 | 91 |
92 timeout.Cancel(); | 92 timeout.Cancel(); |
93 } | 93 } |
94 | 94 |
95 // A helper function to call ReadFilteredData on a policy object and wait for | 95 // A helper function to call ReadFilteredData on a policy object and wait for |
96 // the results to be processed. | 96 // the results to be processed. |
(...skipping 16 matching lines...) Expand all Loading... | |
113 arg_url, | 113 arg_url, |
114 base::Bind(&FullStreamUIPolicyTest::CheckWrapper, | 114 base::Bind(&FullStreamUIPolicyTest::CheckWrapper, |
115 checker, | 115 checker, |
116 base::MessageLoop::current()->QuitClosure())); | 116 base::MessageLoop::current()->QuitClosure())); |
117 | 117 |
118 // Set up a timeout that will trigger after 5 seconds; if we haven't | 118 // Set up a timeout that will trigger after 5 seconds; if we haven't |
119 // received any results by then assume that the test is broken. | 119 // received any results by then assume that the test is broken. |
120 base::CancelableClosure timeout( | 120 base::CancelableClosure timeout( |
121 base::Bind(&FullStreamUIPolicyTest::TimeoutCallback)); | 121 base::Bind(&FullStreamUIPolicyTest::TimeoutCallback)); |
122 base::MessageLoop::current()->PostDelayedTask( | 122 base::MessageLoop::current()->PostDelayedTask( |
123 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(5)); | 123 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(5)); |
mvrable
2013/09/05 18:10:55
This is the timeout which is actually used by the
felt
2013/09/05 18:17:56
Whoops, forgot my other CL (which removes the redu
| |
124 | 124 |
125 // Wait for results; either the checker or the timeout callbacks should | 125 // Wait for results; either the checker or the timeout callbacks should |
126 // cause the main loop to exit. | 126 // cause the main loop to exit. |
127 base::MessageLoop::current()->Run(); | 127 base::MessageLoop::current()->Run(); |
128 | 128 |
129 timeout.Cancel(); | 129 timeout.Cancel(); |
130 } | 130 } |
131 | 131 |
132 static void CheckWrapper( | 132 static void CheckWrapper( |
133 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker, | 133 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker, |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
652 FullStreamUIPolicy* policy = new FullStreamUIPolicy(profile_.get()); | 652 FullStreamUIPolicy* policy = new FullStreamUIPolicy(profile_.get()); |
653 | 653 |
654 for (int i = 0; i < 305; i++) { | 654 for (int i = 0; i < 305; i++) { |
655 scoped_refptr<Action> action = | 655 scoped_refptr<Action> action = |
656 new Action("punky", | 656 new Action("punky", |
657 base::Time::Now(), | 657 base::Time::Now(), |
658 Action::ACTION_API_CALL, | 658 Action::ACTION_API_CALL, |
659 base::StringPrintf("apicall_%d", i)); | 659 base::StringPrintf("apicall_%d", i)); |
660 policy->ProcessAction(action); | 660 policy->ProcessAction(action); |
661 } | 661 } |
662 | |
662 policy->Flush(); | 663 policy->Flush(); |
664 WaitOnThread(BrowserThread::DB); | |
663 | 665 |
664 CheckReadFilteredData( | 666 CheckReadFilteredData( |
665 policy, | 667 policy, |
666 "punky", | 668 "punky", |
667 Action::ACTION_ANY, | 669 Action::ACTION_ANY, |
668 "", | 670 "", |
669 "", | 671 "", |
670 "", | 672 "", |
671 base::Bind( | 673 base::Bind( |
672 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions300)); | 674 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions300)); |
673 policy->Close(); | 675 policy->Close(); |
674 } | 676 } |
675 | 677 |
676 } // namespace extensions | 678 } // namespace extensions |
OLD | NEW |