| 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 | |
| 23 namespace { | 19 namespace { |
| 24 | 20 |
| 25 // Event information returned from ping response. | 21 // Event information returned from ping response. |
| 26 struct ReturnedEvent { | 22 struct ReturnedEvent { |
| 27 rlz_lib::AccessPoint access_point; | 23 rlz_lib::AccessPoint access_point; |
| 28 rlz_lib::Event event_type; | 24 rlz_lib::Event event_type; |
| 29 }; | 25 }; |
| 30 | 26 |
| 31 // Helper functions | 27 // Helper functions |
| 32 | 28 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } // namespace | 207 } // namespace |
| 212 | 208 |
| 213 namespace rlz_lib { | 209 namespace rlz_lib { |
| 214 | 210 |
| 215 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) | 211 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) |
| 216 bool SetURLRequestContext(net::URLRequestContextGetter* context) { | 212 bool SetURLRequestContext(net::URLRequestContextGetter* context) { |
| 217 return FinancialPing::SetURLRequestContext(context); | 213 return FinancialPing::SetURLRequestContext(context); |
| 218 } | 214 } |
| 219 #endif | 215 #endif |
| 220 | 216 |
| 221 #if defined(OS_CHROMEOS) | |
| 222 void RLZ_LIB_API SetIOTaskRunner(base::SequencedTaskRunner* io_task_runner) { | |
| 223 RlzValueStoreChromeOS::SetIOTaskRunner(io_task_runner); | |
| 224 } | |
| 225 | |
| 226 void RLZ_LIB_API CleanupRlz() { | |
| 227 RlzValueStoreChromeOS::Cleanup(); | |
| 228 } | |
| 229 #endif | |
| 230 | |
| 231 bool GetProductEventsAsCgi(Product product, char* cgi, size_t cgi_size) { | 217 bool GetProductEventsAsCgi(Product product, char* cgi, size_t cgi_size) { |
| 232 if (!cgi || cgi_size <= 0) { | 218 if (!cgi || cgi_size <= 0) { |
| 233 ASSERT_STRING("GetProductEventsAsCgi: Invalid buffer"); | 219 ASSERT_STRING("GetProductEventsAsCgi: Invalid buffer"); |
| 234 return false; | 220 return false; |
| 235 } | 221 } |
| 236 | 222 |
| 237 cgi[0] = 0; | 223 cgi[0] = 0; |
| 238 | 224 |
| 239 ScopedRlzValueStoreLock lock; | 225 ScopedRlzValueStoreLock lock; |
| 240 RlzValueStore* store = lock.GetStore(); | 226 RlzValueStore* store = lock.GetStore(); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 if (cgi_string.size() >= cgi_size) | 642 if (cgi_string.size() >= cgi_size) |
| 657 return false; | 643 return false; |
| 658 | 644 |
| 659 strncpy(cgi, cgi_string.c_str(), cgi_size); | 645 strncpy(cgi, cgi_string.c_str(), cgi_size); |
| 660 cgi[cgi_size - 1] = 0; | 646 cgi[cgi_size - 1] = 0; |
| 661 | 647 |
| 662 return true; | 648 return true; |
| 663 } | 649 } |
| 664 | 650 |
| 665 } // namespace rlz_lib | 651 } // namespace rlz_lib |
| OLD | NEW |