| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "modules/netinfo/WorkerNavigatorNetworkInformation.h" | 5 #include "modules/netinfo/WorkerNavigatorNetworkInformation.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "core/dom/ExecutionContext.h" |
| 8 #include "core/workers/WorkerNavigator.h" | 9 #include "core/workers/WorkerNavigator.h" |
| 9 #include "modules/netinfo/NetworkInformation.h" | 10 #include "modules/netinfo/NetworkInformation.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 WorkerNavigatorNetworkInformation::WorkerNavigatorNetworkInformation( | 14 WorkerNavigatorNetworkInformation::WorkerNavigatorNetworkInformation( |
| 14 WorkerNavigator& navigator, | 15 WorkerNavigator& navigator, |
| 15 ExecutionContext* context) | 16 ExecutionContext* context) |
| 16 : Supplement<WorkerNavigator>(navigator) {} | 17 : Supplement<WorkerNavigator>(navigator) {} |
| 17 | 18 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 Supplement<WorkerNavigator>::From(navigator, SupplementName())); | 36 Supplement<WorkerNavigator>::From(navigator, SupplementName())); |
| 36 } | 37 } |
| 37 | 38 |
| 38 const char* WorkerNavigatorNetworkInformation::SupplementName() { | 39 const char* WorkerNavigatorNetworkInformation::SupplementName() { |
| 39 return "WorkerNavigatorNetworkInformation"; | 40 return "WorkerNavigatorNetworkInformation"; |
| 40 } | 41 } |
| 41 | 42 |
| 42 NetworkInformation* WorkerNavigatorNetworkInformation::connection( | 43 NetworkInformation* WorkerNavigatorNetworkInformation::connection( |
| 43 ScriptState* script_state, | 44 ScriptState* script_state, |
| 44 WorkerNavigator& navigator) { | 45 WorkerNavigator& navigator) { |
| 45 ExecutionContext* context = script_state->GetExecutionContext(); | 46 ExecutionContext* context = ExecutionContext::From(script_state); |
| 46 return WorkerNavigatorNetworkInformation::From(navigator, context) | 47 return WorkerNavigatorNetworkInformation::From(navigator, context) |
| 47 .connection(context); | 48 .connection(context); |
| 48 } | 49 } |
| 49 | 50 |
| 50 DEFINE_TRACE(WorkerNavigatorNetworkInformation) { | 51 DEFINE_TRACE(WorkerNavigatorNetworkInformation) { |
| 51 visitor->Trace(connection_); | 52 visitor->Trace(connection_); |
| 52 Supplement<WorkerNavigator>::Trace(visitor); | 53 Supplement<WorkerNavigator>::Trace(visitor); |
| 53 } | 54 } |
| 54 | 55 |
| 55 NetworkInformation* WorkerNavigatorNetworkInformation::connection( | 56 NetworkInformation* WorkerNavigatorNetworkInformation::connection( |
| 56 ExecutionContext* context) { | 57 ExecutionContext* context) { |
| 57 ASSERT(context); | 58 ASSERT(context); |
| 58 if (!connection_) | 59 if (!connection_) |
| 59 connection_ = NetworkInformation::Create(context); | 60 connection_ = NetworkInformation::Create(context); |
| 60 return connection_.Get(); | 61 return connection_.Get(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace blink | 64 } // namespace blink |
| OLD | NEW |