| 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 "net/cert/cert_database.h" | 5 #include "net/cert/cert_database.h" |
| 6 | 6 |
| 7 #include <Security/Security.h> | 7 #include <Security/Security.h> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 registered_(false), | 32 registered_(false), |
| 33 called_shutdown_(false) { | 33 called_shutdown_(false) { |
| 34 // Ensure an associated CFRunLoop. | 34 // Ensure an associated CFRunLoop. |
| 35 DCHECK(base::MessageLoopForUI::IsCurrent()); | 35 DCHECK(base::MessageLoopForUI::IsCurrent()); |
| 36 task_runner_ = message_loop->task_runner(); | 36 task_runner_ = message_loop->task_runner(); |
| 37 task_runner_->PostTask(FROM_HERE, | 37 task_runner_->PostTask(FROM_HERE, |
| 38 base::Bind(&Notifier::Init, | 38 base::Bind(&Notifier::Init, |
| 39 base::Unretained(this))); | 39 base::Unretained(this))); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Should be called from the |task_runner_|'s thread. Use Shutdown() | 42 // Should be called from the |task_runner_|'s sequence. Use Shutdown() |
| 43 // to shutdown on arbitrary threads. | 43 // to shutdown on arbitrary sequence. |
| 44 ~Notifier() { | 44 ~Notifier() { |
| 45 DCHECK(called_shutdown_); | 45 DCHECK(called_shutdown_); |
| 46 // Only unregister from the same thread where registration was performed. | 46 // Only unregister from the same sequence where registration was performed. |
| 47 if (registered_ && task_runner_->RunsTasksOnCurrentThread()) | 47 if (registered_ && task_runner_->RunsTasksInCurrentSequence()) |
| 48 SecKeychainRemoveCallback(&Notifier::KeychainCallback); | 48 SecKeychainRemoveCallback(&Notifier::KeychainCallback); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void Shutdown() { | 51 void Shutdown() { |
| 52 called_shutdown_ = true; | 52 called_shutdown_ = true; |
| 53 if (!task_runner_->DeleteSoon(FROM_HERE, this)) { | 53 if (!task_runner_->DeleteSoon(FROM_HERE, this)) { |
| 54 // If the task runner is no longer running, it's safe to just delete | 54 // If the task runner is no longer running, it's safe to just delete |
| 55 // the object, since no further events will or can be delivered by | 55 // the object, since no further events will or can be delivered by |
| 56 // Keychain Services. | 56 // Keychain Services. |
| 57 delete this; | 57 delete this; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 : observer_list_(new base::ObserverListThreadSafe<Observer>) { | 126 : observer_list_(new base::ObserverListThreadSafe<Observer>) { |
| 127 } | 127 } |
| 128 | 128 |
| 129 CertDatabase::~CertDatabase() { | 129 CertDatabase::~CertDatabase() { |
| 130 // Shutdown will take care to delete the notifier on the right thread. | 130 // Shutdown will take care to delete the notifier on the right thread. |
| 131 if (notifier_.get()) | 131 if (notifier_.get()) |
| 132 notifier_.release()->Shutdown(); | 132 notifier_.release()->Shutdown(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace net | 135 } // namespace net |
| OLD | NEW |