Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package prod | 5 package prod |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net/http" | 9 "net/http" |
| 10 "net/http/cookiejar" | 10 "net/http/cookiejar" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 // - github.com/luci/gae/service/urlfetch | 79 // - github.com/luci/gae/service/urlfetch |
| 80 // - github.com/luci/gae/service/user | 80 // - github.com/luci/gae/service/user |
| 81 // | 81 // |
| 82 // These can be retrieved with the <service>.Get functions. | 82 // These can be retrieved with the <service>.Get functions. |
| 83 // | 83 // |
| 84 // The implementations are all backed by the real appengine SDK functionality, | 84 // The implementations are all backed by the real appengine SDK functionality, |
| 85 func Use(c context.Context, r *http.Request) context.Context { | 85 func Use(c context.Context, r *http.Request) context.Context { |
| 86 return setupAECtx(c, appengine.NewContext(r)) | 86 return setupAECtx(c, appengine.NewContext(r)) |
| 87 } | 87 } |
| 88 | 88 |
| 89 // UseBackground is the same as Use except that it activates production | |
| 90 // implementations which aren't associated with any particular request. | |
|
Vadim Sh.
2016/01/25 18:56:17
What are conditions of it working? Can you please
| |
| 91 func UseBackground(c context.Context) context.Context { | |
| 92 return setupAECtx(c, appengine.BackgroundContext()) | |
| 93 } | |
| 94 | |
| 89 // UseRemote is the same as Use, except that it lets you attach a context to | 95 // UseRemote is the same as Use, except that it lets you attach a context to |
| 90 // a remote host using the Remote API feature. See the docs for the | 96 // a remote host using the Remote API feature. See the docs for the |
| 91 // prerequisites. | 97 // prerequisites. |
| 92 // | 98 // |
| 93 // docs: https://cloud.google.com/appengine/docs/go/tools/remoteapi | 99 // docs: https://cloud.google.com/appengine/docs/go/tools/remoteapi |
| 94 // | 100 // |
| 95 // inOutCtx will be replaced with the new, derived context, if err is nil, | 101 // inOutCtx will be replaced with the new, derived context, if err is nil, |
| 96 // otherwise it's unchanged and continues to be safe-to-use. | 102 // otherwise it's unchanged and continues to be safe-to-use. |
| 97 // | 103 // |
| 98 // If client is nil, this will use create a new client, and will try to be | 104 // If client is nil, this will use create a new client, and will try to be |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 } | 156 } |
| 151 } | 157 } |
| 152 | 158 |
| 153 aeCtx, err := remote_api.NewRemoteContext(host, client) | 159 aeCtx, err := remote_api.NewRemoteContext(host, client) |
| 154 if err != nil { | 160 if err != nil { |
| 155 return | 161 return |
| 156 } | 162 } |
| 157 *inOutCtx = setupAECtx(*inOutCtx, aeCtx) | 163 *inOutCtx = setupAECtx(*inOutCtx, aeCtx) |
| 158 return nil | 164 return nil |
| 159 } | 165 } |
| OLD | NEW |