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

Unified Diff: chrome/third_party/mock4js/examples/PriceService.js

Issue 7237030: Added options browser_tests using the generator and js handler framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TestNavigationController in ui_test_utils, renamed LoadStart->JsInjectionReady, reordered methods. Created 9 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
Index: chrome/third_party/mock4js/examples/PriceService.js
diff --git a/chrome/third_party/mock4js/examples/PriceService.js b/chrome/third_party/mock4js/examples/PriceService.js
new file mode 100644
index 0000000000000000000000000000000000000000..f20aa9394c53dfd3f35f04e934951d2e2df212b4
--- /dev/null
+++ b/chrome/third_party/mock4js/examples/PriceService.js
@@ -0,0 +1,43 @@
+/**
+ * PriceCache
+ */
+function PriceCache() {
+}
+
+PriceCache.prototype = {
+ getCachedPrice: function(instrumentId) {
+ },
+ setCachedPrice: function(instrumentId, price) {
+ }
+}
+
+/**
+ * PriceFetcher
+ */
+function PriceFetcher() {
+}
+
+PriceFetcher.prototype = {
+ getPriceFromServer: function(instrumentId) {
+ }
+}
+
+
+/**
+ * PriceService
+ */
+function PriceService(priceFetcher, priceCache) {
+ this._priceFetcher = priceFetcher;
+ this._priceCache = priceCache;
+}
+
+PriceService.prototype = {
+ getPrice: function(instrumentId) {
+ var price = this._priceCache.getCachedPrice(instrumentId);
+ if(price==null) {
+ price = this._priceFetcher.getPriceFromServer(instrumentId);
+ this._priceCache.setCachedPrice(instrumentId, price);
+ }
+ return price;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698