mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This CL factors the network interactions out of DartLoader into a DartLibraryProvider interface, paving the way for other library providers (e.g., offline). As part of this CL, I've renamed DartLoader to DartLibraryLoader and moved the class into tonic, where it can't have any direct network dependencies. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1202283004.
62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/engine/tonic/dart_state.h"
|
|
|
|
#include "sky/engine/tonic/dart_class_library.h"
|
|
#include "sky/engine/tonic/dart_converter.h"
|
|
#include "sky/engine/tonic/dart_exception_factory.h"
|
|
#include "sky/engine/tonic/dart_library_loader.h"
|
|
#include "sky/engine/tonic/dart_string_cache.h"
|
|
#include "sky/engine/tonic/dart_timer_heap.h"
|
|
#include "sky/engine/wtf/PassOwnPtr.h"
|
|
|
|
namespace blink {
|
|
|
|
DartState::Scope::Scope(DartState* dart_state) : scope_(dart_state->isolate()) {
|
|
}
|
|
|
|
DartState::Scope::~Scope() {
|
|
}
|
|
|
|
DartState::DartState()
|
|
: isolate_(NULL),
|
|
class_library_(adoptPtr(new DartClassLibrary)),
|
|
exception_factory_(adoptPtr(new DartExceptionFactory(this))),
|
|
library_loader_(adoptPtr(new DartLibraryLoader(this))),
|
|
string_cache_(adoptPtr(new DartStringCache)),
|
|
timer_heap_(adoptPtr(new DartTimerHeap())),
|
|
weak_factory_(this) {
|
|
}
|
|
|
|
DartState::~DartState() {
|
|
}
|
|
|
|
void DartState::SetIsolate(Dart_Isolate isolate) {
|
|
isolate_ = isolate;
|
|
if (!isolate_)
|
|
return;
|
|
|
|
{
|
|
Scope dart_scope(this);
|
|
index_handle_.Set(this, ToDart("index"));
|
|
}
|
|
|
|
DidSetIsolate();
|
|
}
|
|
|
|
DartState* DartState::From(Dart_Isolate isolate) {
|
|
return static_cast<DartState*>(Dart_IsolateData(isolate));
|
|
}
|
|
|
|
DartState* DartState::Current() {
|
|
return static_cast<DartState*>(Dart_CurrentIsolateData());
|
|
}
|
|
|
|
base::WeakPtr<DartState> DartState::GetWeakPtr() {
|
|
return weak_factory_.GetWeakPtr();
|
|
}
|
|
|
|
} // namespace blink
|