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

Unified Diff: impl/memory/mail.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: Lightning talk licenses. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/memory/info_test.go ('k') | impl/memory/mail_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/mail.go
diff --git a/impl/memory/mail.go b/impl/memory/mail.go
index a99bf950473190565ff270a70b12b331dd7b0205..d772bb2fc98262b48aca7884af7d6856e84e0f8e 100644
--- a/impl/memory/mail.go
+++ b/impl/memory/mail.go
@@ -26,23 +26,23 @@ type mailData struct {
// mailImpl is a contextual pointer to the current mailData.
type mailImpl struct {
- data *mailData
+ context.Context
- c context.Context
+ data *mailData
}
-var _ mail.Interface = (*mailImpl)(nil)
+var _ mail.RawInterface = (*mailImpl)(nil)
-// useMail adds a mail.Interface implementation to context, accessible
-// by mail.Get(c)
+// useMail adds a mail.RawInterface implementation to context, accessible
+// by mail.Raw(c) or the exported mail methods.
func useMail(c context.Context) context.Context {
data := &mailData{
admins: []string{"admin@example.com"},
adminsPlain: []string{"admin@example.com"},
}
- return mail.SetFactory(c, func(c context.Context) mail.Interface {
- return &mailImpl{data, c}
+ return mail.SetFactory(c, func(ic context.Context) mail.RawInterface {
+ return &mailImpl{ic, data}
})
}
@@ -128,8 +128,7 @@ func checkMessage(msg *mail.TestMessage, adminsPlain []string, user string) erro
func (m *mailImpl) sendImpl(msg *mail.Message) error {
email := ""
- userSvc := user.Get(m.c)
- if u := userSvc.Current(); u != nil {
+ if u := user.Current(m); u != nil {
email = u.Email
}
@@ -164,9 +163,7 @@ func (m *mailImpl) SendToAdmins(msg *mail.Message) error {
return m.sendImpl(msg)
}
-func (m *mailImpl) Testable() mail.Testable {
- return m
-}
+func (m *mailImpl) GetTestable() mail.Testable { return m }
func (m *mailImpl) SetAdminEmails(emails ...string) {
adminsPlain := make([]string, len(emails))
« no previous file with comments | « impl/memory/info_test.go ('k') | impl/memory/mail_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698