Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1281)

Unified Diff: tonic/dart_class_library.cc

Issue 1244493002: Wholesale move sky/engine/tonic to tonic (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tonic/dart_class_library.h ('k') | tonic/dart_class_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tonic/dart_class_library.cc
diff --git a/tonic/dart_class_library.cc b/tonic/dart_class_library.cc
new file mode 100644
index 0000000000000000000000000000000000000000..60bc51900eedb3dfa571c80b83370dfc228c32d3
--- /dev/null
+++ b/tonic/dart_class_library.cc
@@ -0,0 +1,34 @@
+// 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 "tonic/dart_class_library.h"
+
+#include "base/logging.h"
+#include "tonic/dart_wrapper_info.h"
+
+namespace blink {
+
+DartClassLibrary::DartClassLibrary() : provider_(nullptr) {
+}
+
+DartClassLibrary::~DartClassLibrary() {
+ // Note that we don't need to delete these persistent handles because this
+ // object lives as long as the isolate. The handles will get deleted when the
+ // isolate dies.
+}
+
+Dart_PersistentHandle DartClassLibrary::GetClass(const DartWrapperInfo& info) {
+ DCHECK(provider_);
+
+ const auto& result = cache_.insert(std::make_pair(&info, nullptr));
+ if (!result.second) {
+ // Already present, return value.
+ return result.first->second;
+ }
+ Dart_Handle class_handle = provider_->GetClassByName(info.interface_name);
+ result.first->second = Dart_NewPersistentHandle(class_handle);
+ return result.first->second;
+}
+
+} // namespace blink
« no previous file with comments | « tonic/dart_class_library.h ('k') | tonic/dart_class_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698