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

Unified Diff: filter/count/user.go

Issue 1530533002: Add filters for user service. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: bug Created 5 years 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 | « filter/count/count_test.go ('k') | filter/featureBreaker/user.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/count/user.go
diff --git a/filter/count/user.go b/filter/count/user.go
new file mode 100644
index 0000000000000000000000000000000000000000..915e636a3b7bbaa27aff5f8f201c77073a50d713
--- /dev/null
+++ b/filter/count/user.go
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package count
+
+import (
+ "github.com/luci/gae/service/user"
+ "golang.org/x/net/context"
+)
+
+// UserCounter is the counter object for the User service.
+type UserCounter struct {
+ Current Entry
+ CurrentOAuth Entry
+ IsAdmin Entry
+ LoginURL Entry
+ LoginURLFederated Entry
+ LogoutURL Entry
+ OAuthConsumerKey Entry
+}
+
+type userCounter struct {
+ c *UserCounter
+
+ u user.Interface
+}
+
+var _ user.Interface = (*userCounter)(nil)
+
+func (u *userCounter) Current() *user.User {
+ u.c.Current.up()
+ return u.u.Current()
+}
+
+func (u *userCounter) CurrentOAuth(scopes ...string) (*user.User, error) {
+ ret, err := u.u.CurrentOAuth(scopes...)
+ return ret, u.c.CurrentOAuth.up(err)
+}
+
+func (u *userCounter) IsAdmin() bool {
+ u.c.IsAdmin.up()
+ return u.u.IsAdmin()
+}
+
+func (u *userCounter) LoginURL(dest string) (string, error) {
+ ret, err := u.u.LoginURL(dest)
+ return ret, u.c.LoginURL.up(err)
+}
+
+func (u *userCounter) LoginURLFederated(dest, identity string) (string, error) {
+ ret, err := u.u.LoginURLFederated(dest, identity)
+ return ret, u.c.LoginURLFederated.up(err)
+}
+
+func (u *userCounter) LogoutURL(dest string) (string, error) {
+ ret, err := u.u.LogoutURL(dest)
+ return ret, u.c.LogoutURL.up(err)
+}
+
+func (u *userCounter) OAuthConsumerKey() (string, error) {
+ ret, err := u.u.OAuthConsumerKey()
+ return ret, u.c.OAuthConsumerKey.up(err)
+}
+
+func (u *userCounter) Testable() user.Testable {
+ return u.u.Testable()
+}
+
+// FilterUser installs a counter User filter in the context.
+func FilterUser(c context.Context) (context.Context, *UserCounter) {
+ state := &UserCounter{}
+ return user.AddFilters(c, func(ic context.Context, u user.Interface) user.Interface {
+ return &userCounter{state, u}
+ }), state
+}
« no previous file with comments | « filter/count/count_test.go ('k') | filter/featureBreaker/user.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698