| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 return aeCtx | 50 return aeCtx |
| 51 } | 51 } |
| 52 | 52 |
| 53 // AEContextNoTxn retrieves the raw "google.golang.org/appengine" compatible | 53 // AEContextNoTxn retrieves the raw "google.golang.org/appengine" compatible |
| 54 // Context that's not part of a transaction. | 54 // Context that's not part of a transaction. |
| 55 func AEContextNoTxn(c context.Context) context.Context { | 55 func AEContextNoTxn(c context.Context) context.Context { |
| 56 aeCtx, _ := c.Value(prodContextNoTxnKey).(context.Context) | 56 aeCtx, _ := c.Value(prodContextNoTxnKey).(context.Context) |
| 57 if aeCtx == nil { | 57 if aeCtx == nil { |
| 58 return nil | 58 return nil |
| 59 } | 59 } |
| 60 » aeCtx, err := appengine.Namespace(aeCtx, info.Get(c).GetNamespace()) | 60 |
| 61 » if err != nil { | 61 » if ns, has := info.Get(c).GetNamespace(); has { |
| 62 » » panic(err) | 62 » » var err error |
| 63 » » aeCtx, err = appengine.Namespace(aeCtx, ns) |
| 64 » » if err != nil { |
| 65 » » » panic(err) |
| 66 » » } |
| 63 } | 67 } |
| 64 if deadline, ok := c.Deadline(); ok { | 68 if deadline, ok := c.Deadline(); ok { |
| 65 aeCtx, _ = context.WithDeadline(aeCtx, deadline) | 69 aeCtx, _ = context.WithDeadline(aeCtx, deadline) |
| 66 } | 70 } |
| 67 return aeCtx | 71 return aeCtx |
| 68 } | 72 } |
| 69 | 73 |
| 70 func setupAECtx(c, aeCtx context.Context) context.Context { | 74 func setupAECtx(c, aeCtx context.Context) context.Context { |
| 71 c = context.WithValue(c, prodContextKey, aeCtx) | 75 c = context.WithValue(c, prodContextKey, aeCtx) |
| 72 c = context.WithValue(c, prodContextNoTxnKey, aeCtx) | 76 c = context.WithValue(c, prodContextNoTxnKey, aeCtx) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 158 } |
| 155 } | 159 } |
| 156 | 160 |
| 157 aeCtx, err := remote_api.NewRemoteContext(host, client) | 161 aeCtx, err := remote_api.NewRemoteContext(host, client) |
| 158 if err != nil { | 162 if err != nil { |
| 159 return | 163 return |
| 160 } | 164 } |
| 161 *inOutCtx = setupAECtx(*inOutCtx, aeCtx) | 165 *inOutCtx = setupAECtx(*inOutCtx, aeCtx) |
| 162 return nil | 166 return nil |
| 163 } | 167 } |
| OLD | NEW |