| 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 11 matching lines...) Expand all Loading... |
| 108 policy->ReadFilteredData( | 108 policy->ReadFilteredData( |
| 109 extension_id, | 109 extension_id, |
| 110 type, | 110 type, |
| 111 api_name, | 111 api_name, |
| 112 page_url, | 112 page_url, |
| 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 8 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(8)); |
| 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 BrowserThread::PostTaskAndReply( |
| 665 BrowserThread::DB, |
| 666 FROM_HERE, |
| 667 base::Bind(&base::DoNothing), |
| 668 base::MessageLoop::current()->QuitClosure()); |
| 669 base::MessageLoop::current()->Run(); |
| 663 | 670 |
| 664 CheckReadFilteredData( | 671 CheckReadFilteredData( |
| 665 policy, | 672 policy, |
| 666 "punky", | 673 "punky", |
| 667 Action::ACTION_ANY, | 674 Action::ACTION_ANY, |
| 668 "", | 675 "", |
| 669 "", | 676 "", |
| 670 "", | 677 "", |
| 671 base::Bind( | 678 base::Bind( |
| 672 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions300)); | 679 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions300)); |
| 673 policy->Close(); | 680 policy->Close(); |
| 674 } | 681 } |
| 675 | 682 |
| 676 } // namespace extensions | 683 } // namespace extensions |
| OLD | NEW |