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 "jingle/notifier/listener/non_blocking_push_client.h" | 5 #include "jingle/notifier/listener/non_blocking_push_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/thread_task_runner_handle.h" |
11 #include "jingle/notifier/listener/push_client_observer.h" | 11 #include "jingle/notifier/listener/push_client_observer.h" |
12 | 12 |
13 namespace notifier { | 13 namespace notifier { |
14 | 14 |
15 // All methods are called on the delegate thread unless specified | 15 // All methods are called on the delegate thread unless specified |
16 // otherwise. | 16 // otherwise. |
17 class NonBlockingPushClient::Core | 17 class NonBlockingPushClient::Core |
18 : public base::RefCountedThreadSafe<NonBlockingPushClient::Core>, | 18 : public base::RefCountedThreadSafe<NonBlockingPushClient::Core>, |
19 public PushClientObserver { | 19 public PushClientObserver { |
20 public: | 20 public: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 const base::WeakPtr<NonBlockingPushClient> parent_push_client_; | 57 const base::WeakPtr<NonBlockingPushClient> parent_push_client_; |
58 scoped_ptr<PushClient> delegate_push_client_; | 58 scoped_ptr<PushClient> delegate_push_client_; |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(Core); | 60 DISALLOW_COPY_AND_ASSIGN(Core); |
61 }; | 61 }; |
62 | 62 |
63 NonBlockingPushClient::Core::Core( | 63 NonBlockingPushClient::Core::Core( |
64 const scoped_refptr<base::SingleThreadTaskRunner>& delegate_task_runner, | 64 const scoped_refptr<base::SingleThreadTaskRunner>& delegate_task_runner, |
65 const base::WeakPtr<NonBlockingPushClient>& parent_push_client) | 65 const base::WeakPtr<NonBlockingPushClient>& parent_push_client) |
66 : parent_task_runner_(base::MessageLoopProxy::current()), | 66 : parent_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
67 delegate_task_runner_(delegate_task_runner), | 67 delegate_task_runner_(delegate_task_runner), |
68 parent_push_client_(parent_push_client) {} | 68 parent_push_client_(parent_push_client) {} |
69 | 69 |
70 NonBlockingPushClient::Core::~Core() { | 70 NonBlockingPushClient::Core::~Core() { |
71 DCHECK(parent_task_runner_->BelongsToCurrentThread() || | 71 DCHECK(parent_task_runner_->BelongsToCurrentThread() || |
72 delegate_task_runner_->BelongsToCurrentThread()); | 72 delegate_task_runner_->BelongsToCurrentThread()); |
73 DCHECK(!delegate_push_client_.get()); | 73 DCHECK(!delegate_push_client_.get()); |
74 } | 74 } |
75 | 75 |
76 void NonBlockingPushClient::Core::CreateOnDelegateThread( | 76 void NonBlockingPushClient::Core::CreateOnDelegateThread( |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 FOR_EACH_OBSERVER(PushClientObserver, observers_, | 234 FOR_EACH_OBSERVER(PushClientObserver, observers_, |
235 OnIncomingNotification(notification)); | 235 OnIncomingNotification(notification)); |
236 } | 236 } |
237 | 237 |
238 void NonBlockingPushClient::OnPingResponse() { | 238 void NonBlockingPushClient::OnPingResponse() { |
239 DCHECK(thread_checker_.CalledOnValidThread()); | 239 DCHECK(thread_checker_.CalledOnValidThread()); |
240 FOR_EACH_OBSERVER(PushClientObserver, observers_, OnPingResponse()); | 240 FOR_EACH_OBSERVER(PushClientObserver, observers_, OnPingResponse()); |
241 } | 241 } |
242 | 242 |
243 } // namespace notifier | 243 } // namespace notifier |
OLD | NEW |