| Index: service/module/context.go
|
| diff --git a/service/info/context.go b/service/module/context.go
|
| similarity index 78%
|
| copy from service/info/context.go
|
| copy to service/module/context.go
|
| index 21d5000b420580c15a10b2a24715856df57e4964..699eb90ee31b162e6fdd9d94dea9df6e584d91d9 100644
|
| --- a/service/info/context.go
|
| +++ b/service/module/context.go
|
| @@ -1,8 +1,8 @@
|
| -// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Copyright 2016 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 info
|
| +package module
|
|
|
| import (
|
| "golang.org/x/net/context"
|
| @@ -11,23 +11,23 @@ import (
|
| type key int
|
|
|
| var (
|
| - infoKey key
|
| - infoFilterKey key = 1
|
| + moduleKey key
|
| + moduleFilterKey key = 1
|
| )
|
|
|
| // Factory is the function signature for factory methods compatible with
|
| // SetFactory.
|
| type Factory func(context.Context) Interface
|
|
|
| -// Filter is the function signature for a filter GI implementation. It
|
| -// gets the current GI implementation, and returns a new GI implementation
|
| +// Filter is the function signature for a filter module implementation. It gets
|
| +// the current module implementation, and returns a new module implementation
|
| // backed by the one passed in.
|
| type Filter func(context.Context, Interface) Interface
|
|
|
| // getUnfiltered gets gets the Interface implementation from context without
|
| // any of the filters applied.
|
| func getUnfiltered(c context.Context) Interface {
|
| - if f, ok := c.Value(infoKey).(Factory); ok && f != nil {
|
| + if f, ok := c.Value(moduleKey).(Factory); ok && f != nil {
|
| return f(c)
|
| }
|
| return nil
|
| @@ -48,7 +48,7 @@ func Get(c context.Context) Interface {
|
| // SetFactory sets the function to produce Interface instances, as returned
|
| // by the Get method.
|
| func SetFactory(c context.Context, gif Factory) context.Context {
|
| - return context.WithValue(c, infoKey, gif)
|
| + return context.WithValue(c, moduleKey, gif)
|
| }
|
|
|
| // Set sets the current Interface object in the context. Useful for testing
|
| @@ -59,7 +59,7 @@ func Set(c context.Context, gi Interface) context.Context {
|
| }
|
|
|
| func getCurFilters(c context.Context) []Filter {
|
| - curFiltsI := c.Value(infoFilterKey)
|
| + curFiltsI := c.Value(moduleFilterKey)
|
| if curFiltsI != nil {
|
| return curFiltsI.([]Filter)
|
| }
|
| @@ -75,5 +75,5 @@ func AddFilters(c context.Context, filts ...Filter) context.Context {
|
| newFilts := make([]Filter, 0, len(cur)+len(filts))
|
| newFilts = append(newFilts, getCurFilters(c)...)
|
| newFilts = append(newFilts, filts...)
|
| - return context.WithValue(c, infoFilterKey, newFilts)
|
| + return context.WithValue(c, moduleFilterKey, newFilts)
|
| }
|
|
|