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

Unified Diff: chrome/common/extensions/docs/server2/lazy_value.py

Issue 10704252: Extensions Docs Server: Internal file system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests Created 8 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/common/extensions/docs/server2/lazy_value.py
diff --git a/chrome/common/extensions/docs/server2/lazy_value.py b/chrome/common/extensions/docs/server2/lazy_value.py
new file mode 100644
index 0000000000000000000000000000000000000000..43487487198700a5b3b29aa32708c4fe8d489290
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/lazy_value.py
@@ -0,0 +1,26 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+_no_value = object()
+
+class LazyValue(object):
not at google - send to devlin 2012/07/18 10:39:15 I realised today that this isn't *like* Java's Fut
cduvall 2012/07/18 21:26:10 Done.
+ def __init__(self, value=_no_value, error=None, delegate=None):
+ self._value = value
+ self._error = error
+ self._delegate = delegate
+ if (self._value is _no_value and
+ self._error is None and
+ self._delegate is None):
not at google - send to devlin 2012/07/18 10:39:15 what's wrong with ==
cduvall 2012/07/18 21:26:10 See previous comment.
+ raise ValueError('Must have either a value, error, or delegate.')
+
+ def Get(self):
not at google - send to devlin 2012/07/18 10:39:15 documentation
cduvall 2012/07/18 21:26:10 Done.
+ if self._value is not _no_value:
+ return self._value
+ if self._error is not None:
not at google - send to devlin 2012/07/18 10:39:15 what's wrong with !=
cduvall 2012/07/18 21:26:10 See previous comment.
+ raise self._error
+ try:
+ self._value = self._delegate.Get()
+ except Exception as self._error:
+ raise
+ return self._value

Powered by Google App Engine
This is Rietveld 408576698