Refactor ProtectedMediaIdentifierPermissionContext to derive from PermissionContextBase.
[chromium-blink-merge.git] / chrome / third_party / mock4js / examples / PriceService.js
blob825fd8823d5868c927f385ea375f959d98838115
1 /**
2  * PriceCache
3  */
4 function PriceCache() {
7 PriceCache.prototype = {
8         getCachedPrice: function(instrumentId) {
9         },
10         setCachedPrice: function(instrumentId, price) {
11         }
14 /**
15  * PriceFetcher
16  */
17 function PriceFetcher() {
20 PriceFetcher.prototype = {
21         getPriceFromServer: function(instrumentId) {
22         }
26 /**
27  * PriceService
28  */
29 function PriceService(priceFetcher, priceCache) {
30         this._priceFetcher = priceFetcher;
31         this._priceCache = priceCache;
34 PriceService.prototype = {
35         getPrice: function(instrumentId) {
36                 var price = this._priceCache.getCachedPrice(instrumentId);
37                 if(price==null) {
38                         price = this._priceFetcher.getPriceFromServer(instrumentId);
39                         this._priceCache.setCachedPrice(instrumentId, price);
40                 }
41                 return price;
42         }