OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/rlz/rlz_extension_api.h" | 5 #include "chrome/browser/rlz/rlz_extension_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::ThreadRestrictions::ScopedAllowIO allow_io; | 106 base::ThreadRestrictions::ScopedAllowIO allow_io; |
107 | 107 |
108 std::string ap_name; | 108 std::string ap_name; |
109 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &ap_name)); | 109 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &ap_name)); |
110 rlz_lib::AccessPoint access_point; | 110 rlz_lib::AccessPoint access_point; |
111 EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName(ap_name.c_str(), | 111 EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName(ap_name.c_str(), |
112 &access_point)); | 112 &access_point)); |
113 | 113 |
114 char rlz[rlz_lib::kMaxRlzLength + 1]; | 114 char rlz[rlz_lib::kMaxRlzLength + 1]; |
115 rlz_lib::GetAccessPointRlz(access_point, rlz, rlz_lib::kMaxRlzLength); | 115 rlz_lib::GetAccessPointRlz(access_point, rlz, rlz_lib::kMaxRlzLength); |
116 result_.reset(Value::CreateStringValue(rlz)); | 116 SetResult(Value::CreateStringValue(rlz)); |
117 return true; | 117 return true; |
118 } | 118 } |
119 | 119 |
120 RlzSendFinancialPingFunction::RlzSendFinancialPingFunction() | 120 RlzSendFinancialPingFunction::RlzSendFinancialPingFunction() |
121 : product_(rlz_lib::CHROME), | 121 : product_(rlz_lib::CHROME), |
122 exclude_machine_id_(true) { | 122 exclude_machine_id_(true) { |
123 } | 123 } |
124 | 124 |
125 RlzSendFinancialPingFunction::~RlzSendFinancialPingFunction() { | 125 RlzSendFinancialPingFunction::~RlzSendFinancialPingFunction() { |
126 } | 126 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // any 24-hour period. Calling it more often has no effect. If a ping is | 172 // any 24-hour period. Calling it more often has no effect. If a ping is |
173 // not sent false is returned, but this is not an error, so we should not | 173 // not sent false is returned, but this is not an error, so we should not |
174 // use the return value of rlz_lib::SendFinancialPing() as the return value | 174 // use the return value of rlz_lib::SendFinancialPing() as the return value |
175 // of this function. Callers interested in the return value can register | 175 // of this function. Callers interested in the return value can register |
176 // an optional callback function. | 176 // an optional callback function. |
177 bool sent = rlz_lib::SendFinancialPing(product_, access_points_.get(), | 177 bool sent = rlz_lib::SendFinancialPing(product_, access_points_.get(), |
178 signature_.c_str(), brand_.c_str(), | 178 signature_.c_str(), brand_.c_str(), |
179 id_.c_str(), lang_.c_str(), | 179 id_.c_str(), lang_.c_str(), |
180 exclude_machine_id_); | 180 exclude_machine_id_); |
181 | 181 |
182 result_.reset(Value::CreateBooleanValue(sent)); | 182 SetResult(Value::CreateBooleanValue(sent)); |
183 | 183 |
184 bool post_task_result = content::BrowserThread::PostTask( | 184 bool post_task_result = content::BrowserThread::PostTask( |
185 content::BrowserThread::UI, FROM_HERE, | 185 content::BrowserThread::UI, FROM_HERE, |
186 base::Bind(&RlzSendFinancialPingFunction::RespondOnUIThread, this)); | 186 base::Bind(&RlzSendFinancialPingFunction::RespondOnUIThread, this)); |
187 DCHECK(post_task_result); | 187 DCHECK(post_task_result); |
188 } | 188 } |
189 | 189 |
190 void RlzSendFinancialPingFunction::RespondOnUIThread() { | 190 void RlzSendFinancialPingFunction::RespondOnUIThread() { |
191 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 191 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
192 SendResponse(true); | 192 SendResponse(true); |
(...skipping 27 matching lines...) Expand all Loading... |
220 std::string ap_name; | 220 std::string ap_name; |
221 EXTENSION_FUNCTION_VALIDATE(access_points_list->GetString(i, &ap_name)); | 221 EXTENSION_FUNCTION_VALIDATE(access_points_list->GetString(i, &ap_name)); |
222 EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName( | 222 EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName( |
223 ap_name.c_str(), &access_points[i])); | 223 ap_name.c_str(), &access_points[i])); |
224 } | 224 } |
225 access_points[i] = rlz_lib::NO_ACCESS_POINT; | 225 access_points[i] = rlz_lib::NO_ACCESS_POINT; |
226 | 226 |
227 rlz_lib::ClearProductState(product, access_points.get()); | 227 rlz_lib::ClearProductState(product, access_points.get()); |
228 return true; | 228 return true; |
229 } | 229 } |
OLD | NEW |