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

Side by Side Diff: sky/examples/stocks-fn/lib/stock_data.dart

Issue 1028243003: Let Dart code running in Sky add events to the trace timeline (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: more Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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 import 'dart:convert'; 5 import 'dart:convert';
6 import 'dart:math'; 6 import 'dart:math';
7 import 'package:sky/framework/net/fetch.dart'; 7 import 'package:sky/framework/net/fetch.dart';
8 import 'package:sky/framework/tracing.dart';
8 9
9 // Snapshot from http://www.nasdaq.com/screening/company-list.aspx 10 // Snapshot from http://www.nasdaq.com/screening/company-list.aspx
10 // Fetched 2/23/2014. 11 // Fetched 2/23/2014.
11 // "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Summary Quote", 12 // "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Summary Quote",
12 // final List<List<String>> _kCompanyList = [ 13 // Data in stock_data.json
13 // ["TFSC","1347 Capital Corp.","9.43","\$56.09M","2014","Finance","Business S ervices","http://www.nasdaq.com/symbol/tfsc"],
14 // ["TFSCR","1347 Capital Corp.","0.37","n/a","2014","Finance","Business Servi ces","http://www.nasdaq.com/symbol/tfscr"],
15 // ["TFSCU","1347 Capital Corp.","9.97","\$41.67M","2014","n/a","n/a","http:// www.nasdaq.com/symbol/tfscu"],
16 // ["TFSCW","1347 Capital Corp.","0.2","n/a","2014","Finance","Business Servic es","http://www.nasdaq.com/symbol/tfscw"],
17 // ];
18 14
19 class Stock { 15 class Stock {
20 String symbol; 16 String symbol;
21 String name; 17 String name;
22 double lastSale; 18 double lastSale;
23 String marketCap; 19 String marketCap;
24 double percentChange; 20 double percentChange;
25 21
26 Stock(this.symbol, this.name, this.lastSale, this.marketCap, this.percentChang e); 22 Stock(this.symbol, this.name, this.lastSale, this.marketCap, this.percentChang e);
27 23
(...skipping 25 matching lines...) Expand all
53 this.stocks.forEach((stock) { 49 this.stocks.forEach((stock) {
54 if (stock.symbol == symbol) 50 if (stock.symbol == symbol)
55 return stock; 51 return stock;
56 }); 52 });
57 return null; 53 return null;
58 } 54 }
59 } 55 }
60 56
61 Future<StockOracle> fetchStockOracle() async { 57 Future<StockOracle> fetchStockOracle() async {
62 Response response = await fetch('lib/stock_data.json'); 58 Response response = await fetch('lib/stock_data.json');
63 String json = response.bodyAsString(); 59
64 JsonDecoder decoder = new JsonDecoder(); 60 return trace('stocks::fetchStockOracle', () {
65 var companyList = decoder.convert(json); 61 String json = response.bodyAsString();
66 return new StockOracle.fromCompanyList(companyList); 62 JsonDecoder decoder = new JsonDecoder();
63 var companyList = decoder.convert(json);
64 return new StockOracle.fromCompanyList(companyList);
65 });
67 } 66 }
OLDNEW
« no previous file with comments | « sky/examples/stocks-fn/lib/stock_app.dart ('k') | sky/framework/components/fixed_height_scrollable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698