NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / third_party / mock4js / examples / PriceService.js
blobf20aa9394c53dfd3f35f04e934951d2e2df212b4
1 /**\r
2  * PriceCache\r
3  */\r
4 function PriceCache() {\r
5 }\r
6 \r
7 PriceCache.prototype = {\r
8         getCachedPrice: function(instrumentId) {\r
9         },\r
10         setCachedPrice: function(instrumentId, price) {\r
11         }\r
12 }\r
14 /**\r
15  * PriceFetcher\r
16  */\r
17 function PriceFetcher() {\r
18 }\r
20 PriceFetcher.prototype = {\r
21         getPriceFromServer: function(instrumentId) {\r
22         }\r
23 }\r
26 /**\r
27  * PriceService\r
28  */\r
29 function PriceService(priceFetcher, priceCache) {\r
30         this._priceFetcher = priceFetcher;\r
31         this._priceCache = priceCache;\r
32 }\r
34 PriceService.prototype = {\r
35         getPrice: function(instrumentId) {\r
36                 var price = this._priceCache.getCachedPrice(instrumentId);\r
37                 if(price==null) {\r
38                         price = this._priceFetcher.getPriceFromServer(instrumentId);\r
39                         this._priceCache.setCachedPrice(instrumentId, price);\r
40                 }\r
41                 return price;\r
42         }\r
43 }\r