OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/notifications/notification_platform_bridge_linux.h" | 5 #include "chrome/browser/notifications/notification_platform_bridge_linux.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/barrier_closure.h" | 9 #include "base/barrier_closure.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 class NotificationPlatformBridgeLinuxImpl | 125 class NotificationPlatformBridgeLinuxImpl |
126 : public NotificationPlatformBridge, | 126 : public NotificationPlatformBridge, |
127 public content::NotificationObserver, | 127 public content::NotificationObserver, |
128 public base::RefCountedThreadSafe<NotificationPlatformBridgeLinuxImpl> { | 128 public base::RefCountedThreadSafe<NotificationPlatformBridgeLinuxImpl> { |
129 public: | 129 public: |
130 explicit NotificationPlatformBridgeLinuxImpl(scoped_refptr<dbus::Bus> bus) | 130 explicit NotificationPlatformBridgeLinuxImpl(scoped_refptr<dbus::Bus> bus) |
131 : bus_(bus) { | 131 : bus_(bus) { |
132 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 132 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
133 task_runner_ = base::CreateSingleThreadTaskRunnerWithTraits( | 133 task_runner_ = base::CreateSingleThreadTaskRunnerWithTraits( |
134 base::TaskTraits().MayBlock().WithPriority( | 134 {base::MayBlock(), base::TaskPriority::USER_BLOCKING}); |
135 base::TaskPriority::USER_BLOCKING)); | |
136 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 135 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
137 content::NotificationService::AllSources()); | 136 content::NotificationService::AllSources()); |
138 } | 137 } |
139 | 138 |
140 // InitOnTaskRunner() cannot be posted from within the constructor | 139 // InitOnTaskRunner() cannot be posted from within the constructor |
141 // because of a race condition. The reference count for |this| | 140 // because of a race condition. The reference count for |this| |
142 // starts out as 0. Posting the Init task would increment the count | 141 // starts out as 0. Posting the Init task would increment the count |
143 // to 1. If the task finishes before the constructor returns, the | 142 // to 1. If the task finishes before the constructor returns, the |
144 // count will go to 0 and the object would be prematurely | 143 // count will go to 0 and the object would be prematurely |
145 // destructed. | 144 // destructed. |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 } | 657 } |
659 | 658 |
660 void NotificationPlatformBridgeLinux::SetReadyCallback( | 659 void NotificationPlatformBridgeLinux::SetReadyCallback( |
661 NotificationBridgeReadyCallback callback) { | 660 NotificationBridgeReadyCallback callback) { |
662 impl_->SetReadyCallback(std::move(callback)); | 661 impl_->SetReadyCallback(std::move(callback)); |
663 } | 662 } |
664 | 663 |
665 void NotificationPlatformBridgeLinux::CleanUp() { | 664 void NotificationPlatformBridgeLinux::CleanUp() { |
666 impl_->CleanUp(); | 665 impl_->CleanUp(); |
667 } | 666 } |
OLD | NEW |