| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/client/session/blimp_client_session.h" | 5 #include "blimp/client/session/blimp_client_session.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/sequenced_task_runner.h" |
| 12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/threading/sequenced_task_runner_handle.h" | 14 #include "base/threading/sequenced_task_runner_handle.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "blimp/client/app/blimp_client_switches.h" | 16 #include "blimp/client/app/blimp_client_switches.h" |
| 16 #include "blimp/client/feature/ime_feature.h" | 17 #include "blimp/client/feature/ime_feature.h" |
| 17 #include "blimp/client/feature/navigation_feature.h" | 18 #include "blimp/client/feature/navigation_feature.h" |
| 18 #include "blimp/client/feature/render_widget_feature.h" | 19 #include "blimp/client/feature/render_widget_feature.h" |
| 19 #include "blimp/client/feature/settings_feature.h" | 20 #include "blimp/client/feature/settings_feature.h" |
| 20 #include "blimp/client/feature/tab_control_feature.h" | 21 #include "blimp/client/feature/tab_control_feature.h" |
| 21 #include "blimp/common/blob_cache/in_memory_blob_cache.h" | 22 #include "blimp/common/blob_cache/in_memory_blob_cache.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 | 40 |
| 40 namespace blimp { | 41 namespace blimp { |
| 41 namespace client { | 42 namespace client { |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 // Posts network events to an observer across the IO/UI thread boundary. | 45 // Posts network events to an observer across the IO/UI thread boundary. |
| 45 class CrossThreadNetworkEventObserver : public NetworkEventObserver { | 46 class CrossThreadNetworkEventObserver : public NetworkEventObserver { |
| 46 public: | 47 public: |
| 47 CrossThreadNetworkEventObserver( | 48 CrossThreadNetworkEventObserver( |
| 48 const base::WeakPtr<NetworkEventObserver>& target, | 49 const base::WeakPtr<NetworkEventObserver>& target, |
| 49 const scoped_refptr<base::TaskRunner>& task_runner) | 50 const scoped_refptr<base::SequencedTaskRunner>& task_runner) |
| 50 : target_(target), task_runner_(task_runner) {} | 51 : target_(target), task_runner_(task_runner) {} |
| 51 | 52 |
| 52 ~CrossThreadNetworkEventObserver() override {} | 53 ~CrossThreadNetworkEventObserver() override {} |
| 53 | 54 |
| 54 void OnConnected() override { | 55 void OnConnected() override { |
| 55 task_runner_->PostTask( | 56 task_runner_->PostTask( |
| 56 FROM_HERE, base::Bind(&NetworkEventObserver::OnConnected, target_)); | 57 FROM_HERE, base::Bind(&NetworkEventObserver::OnConnected, target_)); |
| 57 } | 58 } |
| 58 | 59 |
| 59 void OnDisconnected(int result) override { | 60 void OnDisconnected(int result) override { |
| 60 task_runner_->PostTask( | 61 task_runner_->PostTask( |
| 61 FROM_HERE, | 62 FROM_HERE, |
| 62 base::Bind(&NetworkEventObserver::OnDisconnected, target_, result)); | 63 base::Bind(&NetworkEventObserver::OnDisconnected, target_, result)); |
| 63 } | 64 } |
| 64 | 65 |
| 65 private: | 66 private: |
| 66 base::WeakPtr<NetworkEventObserver> target_; | 67 base::WeakPtr<NetworkEventObserver> target_; |
| 67 scoped_refptr<base::TaskRunner> task_runner_; | 68 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(CrossThreadNetworkEventObserver); |
| 68 }; | 71 }; |
| 69 | 72 |
| 70 } // namespace | 73 } // namespace |
| 71 | 74 |
| 72 // This class's functions and destruction are all invoked on the IO thread by | 75 // This class's functions and destruction are all invoked on the IO thread by |
| 73 // the BlimpClientSession. | 76 // the BlimpClientSession. |
| 74 class ClientNetworkComponents : public ConnectionHandler, | 77 class ClientNetworkComponents : public ConnectionHandler, |
| 75 public ConnectionErrorObserver { | 78 public ConnectionErrorObserver { |
| 76 public: | 79 public: |
| 77 // Can be created on any thread. | 80 // Can be created on any thread. |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 return settings_feature_.get(); | 319 return settings_feature_.get(); |
| 317 } | 320 } |
| 318 | 321 |
| 319 BlimpConnectionStatistics* BlimpClientSession::GetBlimpConnectionStatistics() | 322 BlimpConnectionStatistics* BlimpClientSession::GetBlimpConnectionStatistics() |
| 320 const { | 323 const { |
| 321 return blimp_connection_statistics_; | 324 return blimp_connection_statistics_; |
| 322 } | 325 } |
| 323 | 326 |
| 324 } // namespace client | 327 } // namespace client |
| 325 } // namespace blimp | 328 } // namespace blimp |
| OLD | NEW |