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

Side by Side Diff: impl/prod/info.go

Issue 2460473003: impl/prod: Make AEContext private. (Closed)
Patch Set: Update comment. Created 4 years, 1 month 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
« no previous file with comments | « impl/prod/context_vm.go ('k') | impl/prod/logger.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package prod 5 package prod
6 6
7 import ( 7 import (
8 "time" 8 "time"
9 9
10 "github.com/luci/gae/service/info" 10 "github.com/luci/gae/service/info"
11 "golang.org/x/net/context" 11 "golang.org/x/net/context"
12 "google.golang.org/appengine" 12 "google.golang.org/appengine"
13 "google.golang.org/appengine/datastore" 13 "google.golang.org/appengine/datastore"
14 ) 14 )
15 15
16 // useGI adds a gae.GlobalInfo implementation to context, accessible 16 // useGI adds a gae.GlobalInfo implementation to context, accessible
17 // by gae.GetGI(c) 17 // by gae.GetGI(c)
18 func useGI(usrCtx context.Context) context.Context { 18 func useGI(usrCtx context.Context) context.Context {
19 probeCache := getProbeCache(usrCtx) 19 probeCache := getProbeCache(usrCtx)
20 if probeCache == nil { 20 if probeCache == nil {
21 » » usrCtx = withProbeCache(usrCtx, probe(AEContext(usrCtx))) 21 » » usrCtx = withProbeCache(usrCtx, probe(getAEContext(usrCtx)))
22 } 22 }
23 23
24 return info.SetFactory(usrCtx, func(ci context.Context) info.RawInterfac e { 24 return info.SetFactory(usrCtx, func(ci context.Context) info.RawInterfac e {
25 » » return giImpl{ci, AEContext(ci)} 25 » » return giImpl{ci, getAEContext(ci)}
26 }) 26 })
27 } 27 }
28 28
29 type giImpl struct { 29 type giImpl struct {
30 usrCtx context.Context 30 usrCtx context.Context
31 aeCtx context.Context 31 aeCtx context.Context
32 } 32 }
33 33
34 func (g giImpl) AccessToken(scopes ...string) (token string, expiry time.Time, e rr error) { 34 func (g giImpl) AccessToken(scopes ...string) (token string, expiry time.Time, e rr error) {
35 return appengine.AccessToken(g.aeCtx, scopes...) 35 return appengine.AccessToken(g.aeCtx, scopes...)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 func getProbeCache(c context.Context) *infoProbeCache { 149 func getProbeCache(c context.Context) *infoProbeCache {
150 if pc, ok := c.Value(&probeCacheKey).(*infoProbeCache); ok { 150 if pc, ok := c.Value(&probeCacheKey).(*infoProbeCache); ok {
151 return pc 151 return pc
152 } 152 }
153 return nil 153 return nil
154 } 154 }
155 155
156 func withProbeCache(c context.Context, pc *infoProbeCache) context.Context { 156 func withProbeCache(c context.Context, pc *infoProbeCache) context.Context {
157 return context.WithValue(c, &probeCacheKey, pc) 157 return context.WithValue(c, &probeCacheKey, pc)
158 } 158 }
OLDNEW
« no previous file with comments | « impl/prod/context_vm.go ('k') | impl/prod/logger.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698