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

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

Issue 10704252: Extensions Docs Server: Internal file system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed up 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/future.py
diff --git a/chrome/common/extensions/docs/server2/future.py b/chrome/common/extensions/docs/server2/future.py
new file mode 100644
index 0000000000000000000000000000000000000000..98deef625042b7da53942637c93beeb8cef43edd
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/future.py
@@ -0,0 +1,30 @@
+# 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 Future(object):
+ """Stores a value, error, or delegate to be used later.
+ """
+ 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):
+ raise ValueError('Must have either a value, error, or delegate.')
+
+ def Get(self):
+ """Gets the stored value, error, or delegate contents.
+ """
+ if self._value is not _no_value:
+ return self._value
+ if self._error is not None:
+ 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