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