| 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 "chrome/browser/extensions/activity_log/counting_policy.h" | 5 #include "chrome/browser/extensions/activity_log/counting_policy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 base::RunLoop().RunUntilIdle(); | 68 base::RunLoop().RunUntilIdle(); |
| 69 profile_.reset(NULL); | 69 profile_.reset(NULL); |
| 70 base::RunLoop().RunUntilIdle(); | 70 base::RunLoop().RunUntilIdle(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Wait for the task queue for the specified thread to empty. | 73 // Wait for the task queue for the specified thread to empty. |
| 74 void WaitOnThread(const BrowserThread::ID& thread) { | 74 void WaitOnThread(const BrowserThread::ID& thread) { |
| 75 BrowserThread::PostTaskAndReply( | 75 BrowserThread::PostTaskAndReply( |
| 76 thread, FROM_HERE, base::Bind(&base::DoNothing), | 76 thread, FROM_HERE, base::Bind(&base::DoNothing), |
| 77 base::MessageLoop::current()->QuitWhenIdleClosure()); | 77 base::MessageLoop::current()->QuitWhenIdleClosure()); |
| 78 base::MessageLoop::current()->Run(); | 78 base::RunLoop().Run(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // A wrapper function for CheckReadFilteredData, so that we don't need to | 81 // A wrapper function for CheckReadFilteredData, so that we don't need to |
| 82 // enter empty string values for parameters we don't care about. | 82 // enter empty string values for parameters we don't care about. |
| 83 void CheckReadData(ActivityLogDatabasePolicy* policy, | 83 void CheckReadData(ActivityLogDatabasePolicy* policy, |
| 84 const std::string& extension_id, | 84 const std::string& extension_id, |
| 85 int day, | 85 int day, |
| 86 const base::Callback<void( | 86 const base::Callback<void( |
| 87 std::unique_ptr<Action::ActionVector>)>& checker) { | 87 std::unique_ptr<Action::ActionVector>)>& checker) { |
| 88 CheckReadFilteredData( | 88 CheckReadFilteredData( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 111 | 111 |
| 112 // Set up a timeout for receiving results; if we haven't received anything | 112 // Set up a timeout for receiving results; if we haven't received anything |
| 113 // when the timeout triggers then assume that the test is broken. | 113 // when the timeout triggers then assume that the test is broken. |
| 114 base::CancelableClosure timeout( | 114 base::CancelableClosure timeout( |
| 115 base::Bind(&CountingPolicyTest::TimeoutCallback)); | 115 base::Bind(&CountingPolicyTest::TimeoutCallback)); |
| 116 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 116 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 117 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); | 117 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); |
| 118 | 118 |
| 119 // Wait for results; either the checker or the timeout callbacks should | 119 // Wait for results; either the checker or the timeout callbacks should |
| 120 // cause the main loop to exit. | 120 // cause the main loop to exit. |
| 121 base::MessageLoop::current()->Run(); | 121 base::RunLoop().Run(); |
| 122 | 122 |
| 123 timeout.Cancel(); | 123 timeout.Cancel(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // A helper function which verifies that the string_ids and url_ids tables in | 126 // A helper function which verifies that the string_ids and url_ids tables in |
| 127 // the database have the specified sizes. | 127 // the database have the specified sizes. |
| 128 static void CheckStringTableSizes(CountingPolicy* policy, | 128 static void CheckStringTableSizes(CountingPolicy* policy, |
| 129 int string_size, | 129 int string_size, |
| 130 int url_size) { | 130 int url_size) { |
| 131 sql::Connection* db = policy->GetDatabaseConnection(); | 131 sql::Connection* db = policy->GetDatabaseConnection(); |
| (...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 | 1412 |
| 1413 action_ids.push_back(2); | 1413 action_ids.push_back(2); |
| 1414 CheckRemoveActions( | 1414 CheckRemoveActions( |
| 1415 policy, action_ids, base::Bind(&CountingPolicyTest::Action2Deleted)); | 1415 policy, action_ids, base::Bind(&CountingPolicyTest::Action2Deleted)); |
| 1416 action_ids.clear(); | 1416 action_ids.clear(); |
| 1417 | 1417 |
| 1418 policy->Close(); | 1418 policy->Close(); |
| 1419 } | 1419 } |
| 1420 | 1420 |
| 1421 } // namespace extensions | 1421 } // namespace extensions |
| OLD | NEW |