| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 void Callback() { | 482 void Callback() { |
| 483 ++callback_count_; | 483 ++callback_count_; |
| 484 } | 484 } |
| 485 | 485 |
| 486 int callback_count() { | 486 int callback_count() { |
| 487 return callback_count_; | 487 return callback_count_; |
| 488 } | 488 } |
| 489 | 489 |
| 490 private: | 490 private: |
| 491 friend class base::RefCountedThreadSafe<CallbackCounter>; | 491 friend class base::RefCountedThreadSafe<CallbackCounter>; |
| 492 ~CallbackCounter() {} |
| 493 |
| 492 volatile int callback_count_; | 494 volatile int callback_count_; |
| 493 }; | 495 }; |
| 494 | 496 |
| 495 // Test that we can get a completion callback after a Flush(). | 497 // Test that we can get a completion callback after a Flush(). |
| 496 TEST_F(SQLiteServerBoundCertStoreTest, TestFlushCompletionCallback) { | 498 TEST_F(SQLiteServerBoundCertStoreTest, TestFlushCompletionCallback) { |
| 497 scoped_refptr<CallbackCounter> counter(new CallbackCounter()); | 499 scoped_refptr<CallbackCounter> counter(new CallbackCounter()); |
| 498 | 500 |
| 499 // Callback shouldn't be invoked until we call Flush(). | 501 // Callback shouldn't be invoked until we call Flush(). |
| 500 ASSERT_EQ(0, counter->callback_count()); | 502 ASSERT_EQ(0, counter->callback_count()); |
| 501 | 503 |
| 502 store_->Flush(base::Bind(&CallbackCounter::Callback, counter.get())); | 504 store_->Flush(base::Bind(&CallbackCounter::Callback, counter.get())); |
| 503 | 505 |
| 504 scoped_refptr<base::ThreadTestHelper> helper( | 506 scoped_refptr<base::ThreadTestHelper> helper( |
| 505 new base::ThreadTestHelper( | 507 new base::ThreadTestHelper( |
| 506 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); | 508 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); |
| 507 ASSERT_TRUE(helper->Run()); | 509 ASSERT_TRUE(helper->Run()); |
| 508 | 510 |
| 509 ASSERT_EQ(1, counter->callback_count()); | 511 ASSERT_EQ(1, counter->callback_count()); |
| 510 } | 512 } |
| OLD | NEW |