| 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 // This file contains types which are mirrors/duplicates of the upstream SDK | 5 // This file contains types which are mirrors/duplicates of the upstream SDK |
| 6 // types. This exists so that users can depend solely on this wrapper library | 6 // types. This exists so that users can depend solely on this wrapper library |
| 7 // without necessarially needing an SDK implementation present. | 7 // without necessarially needing an SDK implementation present. |
| 8 // | 8 // |
| 9 // This was done (instead of type-aliasing from the github version of the SDK) | 9 // This was done (instead of type-aliasing from the github version of the SDK) |
| 10 // because some of the types need to be tweaked (like Task.RetryOptions) to | 10 // because some of the types need to be tweaked (like Task.RetryOptions) to |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // The number of times the task has been dispatched or leased. | 91 // The number of times the task has been dispatched or leased. |
| 92 RetryCount int32 | 92 RetryCount int32 |
| 93 | 93 |
| 94 // Tag for the task. Only used when Method is PULL. | 94 // Tag for the task. Only used when Method is PULL. |
| 95 Tag string | 95 Tag string |
| 96 | 96 |
| 97 // Retry options for this task. May be nil. | 97 // Retry options for this task. May be nil. |
| 98 RetryOptions *RetryOptions | 98 RetryOptions *RetryOptions |
| 99 } | 99 } |
| 100 | 100 |
| 101 // Duplicate returns a deep copy of this Task. |
| 101 func (t *Task) Duplicate() *Task { | 102 func (t *Task) Duplicate() *Task { |
| 102 ret := *t | 103 ret := *t |
| 103 | 104 |
| 104 if len(t.Header) > 0 { | 105 if len(t.Header) > 0 { |
| 105 ret.Header = make(http.Header, len(t.Header)) | 106 ret.Header = make(http.Header, len(t.Header)) |
| 106 for k, vs := range t.Header { | 107 for k, vs := range t.Header { |
| 107 newVs := make([]string, len(vs)) | 108 newVs := make([]string, len(vs)) |
| 108 copy(newVs, vs) | 109 copy(newVs, vs) |
| 109 ret.Header[k] = newVs | 110 ret.Header[k] = newVs |
| 110 } | 111 } |
| 111 } | 112 } |
| 112 | 113 |
| 113 if len(t.Payload) > 0 { | 114 if len(t.Payload) > 0 { |
| 114 ret.Payload = make([]byte, len(t.Payload)) | 115 ret.Payload = make([]byte, len(t.Payload)) |
| 115 copy(ret.Payload, t.Payload) | 116 copy(ret.Payload, t.Payload) |
| 116 } | 117 } |
| 117 | 118 |
| 118 if t.RetryOptions != nil { | 119 if t.RetryOptions != nil { |
| 119 ret.RetryOptions = &RetryOptions{} | 120 ret.RetryOptions = &RetryOptions{} |
| 120 *ret.RetryOptions = *t.RetryOptions | 121 *ret.RetryOptions = *t.RetryOptions |
| 121 } | 122 } |
| 122 | 123 |
| 123 return &ret | 124 return &ret |
| 124 } | 125 } |
| OLD | NEW |