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/location.h" | 7 #include "base/location.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 const Action::ActionType type, | 85 const Action::ActionType type, |
86 const std::string& api_name, | 86 const std::string& api_name, |
87 const std::string& page_url, | 87 const std::string& page_url, |
88 const std::string& arg_url, | 88 const std::string& arg_url, |
89 const int days_ago, | 89 const int days_ago, |
90 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) { | 90 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) { |
91 // Submit a request to the policy to read back some data, and call the | 91 // Submit a request to the policy to read back some data, and call the |
92 // checker function when results are available. This will happen on the | 92 // checker function when results are available. This will happen on the |
93 // database thread. | 93 // database thread. |
94 policy->ReadFilteredData( | 94 policy->ReadFilteredData( |
95 extension_id, | 95 extension_id, type, api_name, page_url, arg_url, days_ago, |
96 type, | 96 base::Bind(&FullStreamUIPolicyTest::CheckWrapper, checker, |
97 api_name, | 97 base::MessageLoop::current()->QuitWhenIdleClosure())); |
98 page_url, | |
99 arg_url, | |
100 days_ago, | |
101 base::Bind(&FullStreamUIPolicyTest::CheckWrapper, | |
102 checker, | |
103 base::MessageLoop::current()->QuitClosure())); | |
104 | 98 |
105 // Set up a timeout for receiving results; if we haven't received anything | 99 // Set up a timeout for receiving results; if we haven't received anything |
106 // when the timeout triggers then assume that the test is broken. | 100 // when the timeout triggers then assume that the test is broken. |
107 base::CancelableClosure timeout( | 101 base::CancelableClosure timeout( |
108 base::Bind(&FullStreamUIPolicyTest::TimeoutCallback)); | 102 base::Bind(&FullStreamUIPolicyTest::TimeoutCallback)); |
109 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 103 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
110 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); | 104 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); |
111 | 105 |
112 // Wait for results; either the checker or the timeout callbacks should | 106 // Wait for results; either the checker or the timeout callbacks should |
113 // cause the main loop to exit. | 107 // cause the main loop to exit. |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 scoped_refptr<Action> action = | 922 scoped_refptr<Action> action = |
929 new Action("punky", | 923 new Action("punky", |
930 base::Time::Now(), | 924 base::Time::Now(), |
931 Action::ACTION_API_CALL, | 925 Action::ACTION_API_CALL, |
932 base::StringPrintf("apicall_%d", i)); | 926 base::StringPrintf("apicall_%d", i)); |
933 policy->ProcessAction(action); | 927 policy->ProcessAction(action); |
934 } | 928 } |
935 | 929 |
936 policy->Flush(); | 930 policy->Flush(); |
937 BrowserThread::PostTaskAndReply( | 931 BrowserThread::PostTaskAndReply( |
938 BrowserThread::DB, | 932 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), |
939 FROM_HERE, | 933 base::MessageLoop::current()->QuitWhenIdleClosure()); |
940 base::Bind(&base::DoNothing), | |
941 base::MessageLoop::current()->QuitClosure()); | |
942 base::MessageLoop::current()->Run(); | 934 base::MessageLoop::current()->Run(); |
943 | 935 |
944 CheckReadFilteredData( | 936 CheckReadFilteredData( |
945 policy, | 937 policy, |
946 "punky", | 938 "punky", |
947 Action::ACTION_ANY, | 939 Action::ACTION_ANY, |
948 "", | 940 "", |
949 "", | 941 "", |
950 "", | 942 "", |
951 -1, | 943 -1, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 action_ids.push_back(3); | 1046 action_ids.push_back(3); |
1055 action_ids.push_back(4); | 1047 action_ids.push_back(4); |
1056 CheckRemoveActions( | 1048 CheckRemoveActions( |
1057 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); | 1049 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); |
1058 action_ids.clear(); | 1050 action_ids.clear(); |
1059 | 1051 |
1060 policy->Close(); | 1052 policy->Close(); |
1061 } | 1053 } |
1062 | 1054 |
1063 } // namespace extensions | 1055 } // namespace extensions |
OLD | NEW |