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

Side by Side Diff: chrome/common/extensions/docs/server2/appengine_url_fetcher.py

Issue 10704252: Extensions Docs Server: Internal file system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: memcache fix 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6 from google.appengine.api import urlfetch
7
8 from future import Future
9
10 class AppEngineUrlFetcher(object):
11 """A wrapper around the App Engine urlfetch module that allows for easy
12 async fetches.
13 """
14 def __init__(self, base_path):
15 self._base_path = base_path
16
17 def Fetch(self, url):
18 """Fetches a file synchronously.
19 """
20 return urlfetch.fetch(self._base_path + '/' + url)
21
22 def FetchAsync(self, url):
23 """Fetches a file asynchronously, and returns a Future with the result.
24 """
25 rpc = urlfetch.create_rpc()
26 urlfetch.make_fetch_call(rpc, self._base_path + '/' + url)
27 return Future(delegate=self._AsyncFetchDelegate(rpc))
28
29 class _AsyncFetchDelegate(object):
not at google - send to devlin 2012/07/19 03:55:19 nit: at top, outside the class scope
cduvall 2012/07/19 17:18:28 Done.
30 def __init__(self, rpc):
31 self._rpc = rpc
32
33 def Get(self):
34 self._rpc.wait()
35 return self._rpc.get_result()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698