| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #library('request_cache'); | |
| 6 | |
| 7 #import('dart:html'); | |
| 8 | |
| 9 /** File system implementation using HTML5's Web Storage. */ | |
| 10 class HttpRequestCache { | |
| 11 final Storage storage; | |
| 12 | |
| 13 HttpRequestCache() : storage = window.sessionStorage; | |
| 14 | |
| 15 String readAll(String filename) { | |
| 16 String response = storage[filename]; | |
| 17 | |
| 18 if (response == null) { | |
| 19 HttpRequest xr = new HttpRequest(); | |
| 20 xr.open("GET", filename, false); | |
| 21 xr.send(); | |
| 22 response = xr.responseText; | |
| 23 storage[filename] = response; | |
| 24 } | |
| 25 return response; | |
| 26 } | |
| 27 } | |
| OLD | NEW |