| 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 // A library to manage RLZ information for access-points shared | 5 // A library to manage RLZ information for access-points shared |
| 6 // across different client applications. | 6 // across different client applications. |
| 7 | 7 |
| 8 #include "rlz/lib/rlz_lib.h" | 8 #include "rlz/lib/rlz_lib.h" |
| 9 | 9 |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "rlz/lib/assert.h" | 12 #include "rlz/lib/assert.h" |
| 13 #include "rlz/lib/crc32.h" | 13 #include "rlz/lib/crc32.h" |
| 14 #include "rlz/lib/financial_ping.h" | 14 #include "rlz/lib/financial_ping.h" |
| 15 #include "rlz/lib/lib_values.h" | 15 #include "rlz/lib/lib_values.h" |
| 16 #include "rlz/lib/rlz_value_store.h" | 16 #include "rlz/lib/rlz_value_store.h" |
| 17 #include "rlz/lib/string_utils.h" | 17 #include "rlz/lib/string_utils.h" |
| 18 | 18 |
| 19 #if defined(OS_CHROMEOS) |
| 20 #include "rlz/chromeos/lib/rlz_value_store_chromeos.h" |
| 21 #endif // defined(OS_CHROMEOS) |
| 22 |
| 19 namespace { | 23 namespace { |
| 20 | 24 |
| 21 // Event information returned from ping response. | 25 // Event information returned from ping response. |
| 22 struct ReturnedEvent { | 26 struct ReturnedEvent { |
| 23 rlz_lib::AccessPoint access_point; | 27 rlz_lib::AccessPoint access_point; |
| 24 rlz_lib::Event event_type; | 28 rlz_lib::Event event_type; |
| 25 }; | 29 }; |
| 26 | 30 |
| 27 // Helper functions | 31 // Helper functions |
| 28 | 32 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } // namespace | 211 } // namespace |
| 208 | 212 |
| 209 namespace rlz_lib { | 213 namespace rlz_lib { |
| 210 | 214 |
| 211 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) | 215 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) |
| 212 bool SetURLRequestContext(net::URLRequestContextGetter* context) { | 216 bool SetURLRequestContext(net::URLRequestContextGetter* context) { |
| 213 return FinancialPing::SetURLRequestContext(context); | 217 return FinancialPing::SetURLRequestContext(context); |
| 214 } | 218 } |
| 215 #endif | 219 #endif |
| 216 | 220 |
| 221 #if defined(OS_CHROMEOS) |
| 222 void RLZ_LIB_API SetIOTaskRunner(base::SequencedTaskRunner* io_task_runner) { |
| 223 RlzValueStoreChromeOS::SetIOTaskRunner(io_task_runner); |
| 224 } |
| 225 #endif |
| 226 |
| 217 bool GetProductEventsAsCgi(Product product, char* cgi, size_t cgi_size) { | 227 bool GetProductEventsAsCgi(Product product, char* cgi, size_t cgi_size) { |
| 218 if (!cgi || cgi_size <= 0) { | 228 if (!cgi || cgi_size <= 0) { |
| 219 ASSERT_STRING("GetProductEventsAsCgi: Invalid buffer"); | 229 ASSERT_STRING("GetProductEventsAsCgi: Invalid buffer"); |
| 220 return false; | 230 return false; |
| 221 } | 231 } |
| 222 | 232 |
| 223 cgi[0] = 0; | 233 cgi[0] = 0; |
| 224 | 234 |
| 225 ScopedRlzValueStoreLock lock; | 235 ScopedRlzValueStoreLock lock; |
| 226 RlzValueStore* store = lock.GetStore(); | 236 RlzValueStore* store = lock.GetStore(); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 if (cgi_string.size() >= cgi_size) | 652 if (cgi_string.size() >= cgi_size) |
| 643 return false; | 653 return false; |
| 644 | 654 |
| 645 strncpy(cgi, cgi_string.c_str(), cgi_size); | 655 strncpy(cgi, cgi_string.c_str(), cgi_size); |
| 646 cgi[cgi_size - 1] = 0; | 656 cgi[cgi_size - 1] = 0; |
| 647 | 657 |
| 648 return true; | 658 return true; |
| 649 } | 659 } |
| 650 | 660 |
| 651 } // namespace rlz_lib | 661 } // namespace rlz_lib |
| OLD | NEW |