// NewReadContext builds a new ReadContext that reads from a given reader
544917
func NewReadContext(source savior.Source) *ReadContext {
	r := &ReadContext{
		source: source,

		offset: 0,

		protoBuffer: proto.NewBuffer(make([]byte, 32*1024)),
	}
	r.countingReader = &countingReader{r}

	source.SetSourceSaveConsumer(&savior.CallbackSourceSaveConsumer{
		OnSave: func(checkpoint *savior.SourceCheckpoint) error {
			savior.Debugf("wire.ReadContext: Source gave us a checkpoint!")

			r.sourceCheckpoint = checkpoint
			r.saveState = saveStateHasSourceCheckpoint

			// we're going to make a full checkpoint on every next read

			return nil
		},
	})

	return r
}
1118461
func NewContext(res http.ResponseWriter, req *http.Request, handlers ...Handler) *Context {
	c := &Context{handlers: handlers}
	c.init(res, req)
	return c
}
284630
func NewContext(ctx context.Context, logger Logger) context.Context {
	return context.WithValue(ctx, "termlog", logger)
}
711802
func NewContext(ctx context.Context, idt *Identity) context.Context {
	return context.WithValue(ctx, idtKey, idt)
}
557394
func NewContext(ctx context.Context, l log15.Logger) context.Context {
	return context.WithValue(ctx, loggerKey, l)
}
1151280
func NewTermContext(ctx IndexReaderContext) *TermContext {
	// assert ctx != nil && ctx.IsTopLevel
	var n int
	if ctx.Leaves() == nil {
		n = 1
	} else {
		n = len(ctx.Leaves())
	}
	return &TermContext{TopReaderContext: ctx, states: make([]TermState, n)}
}
561957
func newContext(ctx context.Context, s *Session) context.Context {
	return context.WithValue(ctx, sessionKey{}, s)
}
381818
func NewContext(req *http.Request) *Context {
	if ae != nil {
		ctxt := ae.NewContext(req)
		return &Context{ae: ctxt}
	}
	return newContext(req)
}
841658
func NewContext(api APIClient, dataDir string) *Context {
	return &Context{
		api:      api,
		dataDir:  dataDir,
		payloads: make(map[string]payload.Payload),
		updates:  make(map[string]payload.Payload),
	}
}
993643
func NewContext() context {
	var ctx context
	ctx.values = make(map[string]map[string]string)

	return ctx
}
1264423
func NewContext(BlockSize int) *Context {
	return &Context{
		blockSize:    BlockSize,
		uniqueHasher: md5.New(),
	}
}
85393
func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrderName string) (*Context, error) {
	universe, err := b.FindTypes()
	if err != nil {
		return nil, err
	}

	c := &Context{
		Namers:   namer.NameSystems{},
		Universe: universe,
		Inputs:   b.FindPackages(),
		FileTypes: map[string]FileType{
			GolangFileType: NewGolangFile(),
		},
		builder: b,
	}

	for name, systemNamer := range nameSystems {
		c.Namers[name] = systemNamer
		if name == canonicalOrderName {
			orderer := namer.Orderer{Namer: systemNamer}
			c.Order = orderer.OrderUniverse(universe)
		}
	}
	return c, nil
}
303650
func NewContext(logger Logger) *Context {
	if logger == nil {
		return nil
	}
	if c, ok := logger.(*Context); ok {
		return c
	}
	ctx := &Context{
		Logger: logger,
	}
	return ctx
}
51086
func (m *Client) NewReaderWithContext(ctx context.Context, name string) (io.ReadCloser, error) {
	if !m.Exists(name) {
		return nil, cloudstorage.ErrObjectNotFound
	}
	get := Concat(m.bucket, name)
	gou.DebugCtx(m.clientCtx, "NewReaderWithContext getting file %s", get)
	f, err := m.client.Open(get)
	if err != nil {
		return nil, err
	}

	return f, nil
}
13116
func NewContext(req *Request, res *Response, f *Fibre) *Context {
	return &Context{
		fibre:    f,
		request:  req,
		response: res,
	}
}
747754
func NewContextMux() *ContextMux {
	mux := New()
	cg := mux.UsingContext()

	return &ContextMux{
		TreeMux:      mux,
		ContextGroup: cg,
	}
}
859519
func NewContext(canvas *js.Object, ca *ContextAttributes) (*Context, error) {
	if js.Global.Get("WebGLRenderingContext") == js.Undefined {
		return nil, errors.New("Your browser doesn't appear to support webgl.")
	}

	if ca == nil {
		ca = DefaultAttributes()
	}

	attrs := map[string]bool{
		"alpha":                 ca.Alpha,
		"depth":                 ca.Depth,
		"stencil":               ca.Stencil,
		"antialias":             ca.Antialias,
		"premultipliedAlpha":    ca.PremultipliedAlpha,
		"preserveDrawingBuffer": ca.PreserveDrawingBuffer,
	}
	gl := canvas.Call("getContext", "webgl", attrs)
	if gl == nil {
		gl = canvas.Call("getContext", "experimental-webgl", attrs)
		if gl == nil {
			return nil, errors.New("Creating a webgl context has failed.")
		}
	}
	ctx := new(Context)
	ctx.Object = gl
	return ctx, nil
}