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

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: 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 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 _AsyncFetchDelegate(object):
11 def __init__(self, rpc):
12 self._rpc = rpc
13
14 def Get(self):
15 self._rpc.wait()
16 return self._rpc.get_result()
17
18 class AppEngineUrlFetcher(object):
19 """A wrapper around the App Engine urlfetch module that allows for easy
20 async fetches.
21 """
22 def __init__(self, base_path):
23 self._base_path = base_path
24
25 def Fetch(self, url):
26 """Fetches a file synchronously.
27 """
28 return urlfetch.fetch(self._base_path + '/' + url)
29
30 def FetchAsync(self, url):
31 """Fetches a file asynchronously, and returns a Future with the result.
32 """
33 rpc = urlfetch.create_rpc()
34 urlfetch.make_fetch_call(rpc, self._base_path + '/' + url)
35 return Future(delegate=_AsyncFetchDelegate(rpc))
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/appengine_memcache.py ('k') | chrome/common/extensions/docs/server2/branch_utility.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698