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

Unified Diff: packages/usage/lib/src/usage_impl_html.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 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 | « packages/usage/lib/src/usage_impl.dart ('k') | packages/usage/lib/src/usage_impl_io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/usage/lib/src/usage_impl_html.dart
diff --git a/packages/usage/lib/src/usage_impl_html.dart b/packages/usage/lib/src/usage_impl_html.dart
index c15cde6ce4159c1121b05991521c5a957606db13..e3f64968fe1f23623253cc27bddc046bf9970ad4 100644
--- a/packages/usage/lib/src/usage_impl_html.dart
+++ b/packages/usage/lib/src/usage_impl_html.dart
@@ -2,43 +2,19 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+library usage_impl_html;
+
import 'dart:async';
import 'dart:convert' show JSON;
import 'dart:html';
import 'usage_impl.dart';
-/// An interface to a Google Analytics session, suitable for use in web apps.
-///
-/// [analyticsUrl] is an optional replacement for the default Google Analytics
-/// URL (`https://www.google-analytics.com/collect`).
-class AnalyticsHtml extends AnalyticsImpl {
- AnalyticsHtml(
- String trackingId, String applicationName, String applicationVersion,
- {String analyticsUrl})
- : super(trackingId, new HtmlPersistentProperties(applicationName),
- new HtmlPostHandler(),
- applicationName: applicationName,
- applicationVersion: applicationVersion,
- analyticsUrl: analyticsUrl) {
- int screenWidth = window.screen.width;
- int screenHeight = window.screen.height;
-
- setSessionValue('sr', '${screenWidth}x$screenHeight');
- setSessionValue('sd', '${window.screen.pixelDepth}-bits');
- setSessionValue('ul', window.navigator.language);
- }
-}
-
-typedef Future<HttpRequest> HttpRequestor(String url,
- {String method, sendData});
-
class HtmlPostHandler extends PostHandler {
- final HttpRequestor mockRequestor;
+ final Function mockRequestor;
- HtmlPostHandler({this.mockRequestor});
+ HtmlPostHandler({Function this.mockRequestor});
- @override
Future sendPost(String url, Map<String, dynamic> parameters) {
int viewportWidth = document.documentElement.clientWidth;
int viewportHeight = document.documentElement.clientHeight;
@@ -46,16 +22,12 @@ class HtmlPostHandler extends PostHandler {
parameters['vp'] = '${viewportWidth}x$viewportHeight';
String data = postEncode(parameters);
- HttpRequestor requestor =
- mockRequestor == null ? HttpRequest.request : mockRequestor;
- return requestor(url, method: 'POST', sendData: data).catchError((e) {
+ var request = mockRequestor == null ? HttpRequest.request : mockRequestor;
+ return request(url, method: 'POST', sendData: data).catchError((e) {
// Catch errors that can happen during a request, but that we can't do
- // anything about, e.g. a missing internet connection.
+ // anything about, e.g. a missing internet conenction.
});
}
-
- @override
- void close() {}
}
class HtmlPersistentProperties extends PersistentProperties {
@@ -67,11 +39,9 @@ class HtmlPersistentProperties extends PersistentProperties {
_map = JSON.decode(str);
}
- @override
- dynamic operator [](String key) => _map[key];
+ dynamic operator[](String key) => _map[key];
- @override
- void operator []=(String key, dynamic value) {
+ void operator[]=(String key, dynamic value) {
if (value == null) {
_map.remove(key);
} else {
@@ -80,7 +50,4 @@ class HtmlPersistentProperties extends PersistentProperties {
window.localStorage[name] = JSON.encode(_map);
}
-
- @override
- void syncSettings() {}
}
« no previous file with comments | « packages/usage/lib/src/usage_impl.dart ('k') | packages/usage/lib/src/usage_impl_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698