| 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 // All functions return true on success and false on error. | 8 // All functions return true on success and false on error. |
| 9 // This implemenation is thread safe. | 9 // This implemenation is thread safe. |
| 10 | 10 |
| 11 | 11 |
| 12 #ifndef RLZ_LIB_RLZ_LIB_H_ | 12 #ifndef RLZ_LIB_RLZ_LIB_H_ |
| 13 #define RLZ_LIB_RLZ_LIB_H_ | 13 #define RLZ_LIB_RLZ_LIB_H_ |
| 14 | 14 |
| 15 #include <stddef.h> | 15 #include <stddef.h> |
| 16 #include <stdio.h> | 16 #include <stdio.h> |
| 17 #include <string> | 17 #include <string> |
| 18 | 18 |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 | 20 |
| 21 #include "rlz/lib/rlz_enums.h" | 21 #include "rlz/lib/rlz_enums.h" |
| 22 | 22 |
| 23 #if defined(OS_WIN) | |
| 24 #define RLZ_LIB_API __cdecl | |
| 25 #else | |
| 26 #define RLZ_LIB_API | |
| 27 #endif | |
| 28 | |
| 29 // Define one of | 23 // Define one of |
| 30 // + RLZ_NETWORK_IMPLEMENTATION_WIN_INET: Uses win inet to send financial pings. | 24 // + RLZ_NETWORK_IMPLEMENTATION_WIN_INET: Uses win inet to send financial pings. |
| 31 // + RLZ_NETWORK_IMPLEMENTATION_CHROME_NET: Uses chrome's network stack to send | 25 // + RLZ_NETWORK_IMPLEMENTATION_CHROME_NET: Uses chrome's network stack to send |
| 32 // financial pings. rlz_lib::SetURLRequestContext() must be called before | 26 // financial pings. rlz_lib::SetURLRequestContext() must be called before |
| 33 // any calls to SendFinancialPing(). | 27 // any calls to SendFinancialPing(). |
| 34 #if defined(RLZ_NETWORK_IMPLEMENTATION_WIN_INET) && \ | 28 #if defined(RLZ_NETWORK_IMPLEMENTATION_WIN_INET) && \ |
| 35 defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) | 29 defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) |
| 36 #error Exactly one of RLZ_NETWORK_IMPLEMENTATION_WIN_INET and \ | 30 #error Exactly one of RLZ_NETWORK_IMPLEMENTATION_WIN_INET and \ |
| 37 RLZ_NETWORK_IMPLEMENTATION_CHROME_NET should be defined. | 31 RLZ_NETWORK_IMPLEMENTATION_CHROME_NET should be defined. |
| 38 #endif | 32 #endif |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Functions which do not access registry will be marked with "no restrictions". | 64 // Functions which do not access registry will be marked with "no restrictions". |
| 71 | 65 |
| 72 class ScopedRlzValueStoreLock; | 66 class ScopedRlzValueStoreLock; |
| 73 | 67 |
| 74 // The maximum length of an access points RLZ in bytes. | 68 // The maximum length of an access points RLZ in bytes. |
| 75 const size_t kMaxRlzLength = 64; | 69 const size_t kMaxRlzLength = 64; |
| 76 // The maximum length of an access points RLZ in bytes. | 70 // The maximum length of an access points RLZ in bytes. |
| 77 const size_t kMaxDccLength = 128; | 71 const size_t kMaxDccLength = 128; |
| 78 // The maximum length of a CGI string in bytes. | 72 // The maximum length of a CGI string in bytes. |
| 79 const size_t kMaxCgiLength = 2048; | 73 const size_t kMaxCgiLength = 2048; |
| 80 // The maximum length of a ping response we will parse in bytes. If the response | |
| 81 // is bigger, please break it up into separate calls. | |
| 82 const size_t kMaxPingResponseLength = 0x4000; // 16K | |
| 83 | 74 |
| 84 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) | 75 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) |
| 85 // Set the URLRequestContextGetter used by SendFinancialPing(). The IO message | 76 // Set the URLRequestContextGetter used by SendFinancialPing(). The IO message |
| 86 // loop returned by this context will be used for the IO done by | 77 // loop returned by this context will be used for the IO done by |
| 87 // SendFinancialPing(). | 78 // SendFinancialPing(). |
| 88 bool RLZ_LIB_API SetURLRequestContext(net::URLRequestContextGetter* context); | 79 bool RLZ_LIB_API SetURLRequestContext(net::URLRequestContextGetter* context); |
| 89 #endif | 80 #endif |
| 90 | 81 |
| 91 // RLZ storage functions. | 82 // RLZ storage functions. |
| 92 | 83 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 bool RLZ_LIB_API FormFinancialPingRequest(Product product, | 161 bool RLZ_LIB_API FormFinancialPingRequest(Product product, |
| 171 const AccessPoint* access_points, | 162 const AccessPoint* access_points, |
| 172 const char* product_signature, | 163 const char* product_signature, |
| 173 const char* product_brand, | 164 const char* product_brand, |
| 174 const char* product_id, | 165 const char* product_id, |
| 175 const char* product_lang, | 166 const char* product_lang, |
| 176 bool exclude_machine_id, | 167 bool exclude_machine_id, |
| 177 char* request, | 168 char* request, |
| 178 size_t request_buffer_size); | 169 size_t request_buffer_size); |
| 179 | 170 |
| 180 // Checks if a ping response is valid - ie. it has a checksum line which | |
| 181 // is the CRC-32 checksum of the message uptil the checksum. If | |
| 182 // checksum_idx is not NULL, it will get the index of the checksum, i.e. - | |
| 183 // the effective end of the message. | |
| 184 // Access: No restrictions. | |
| 185 bool RLZ_LIB_API IsPingResponseValid(const char* response, | |
| 186 int* checksum_idx); | |
| 187 | |
| 188 | |
| 189 // Complex helpers built on top of other functions. | 171 // Complex helpers built on top of other functions. |
| 190 | 172 |
| 191 // Parses the responses from the financial server and updates product state | 173 // Parses the responses from the financial server and updates product state |
| 192 // and access point RLZ's in registry. Like ParsePingResponse(), but also | 174 // and access point RLZ's in registry. Like ParsePingResponse(), but also |
| 193 // updates the last ping time. | 175 // updates the last ping time. |
| 194 // Access: HKCU write. | 176 // Access: HKCU write. |
| 195 bool RLZ_LIB_API ParseFinancialPingResponse(Product product, | 177 bool RLZ_LIB_API ParseFinancialPingResponse(Product product, |
| 196 const char* response); | 178 const char* response); |
| 197 | 179 |
| 198 // Send the ping with RLZs and events to the PSO server. | 180 // Send the ping with RLZs and events to the PSO server. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 303 |
| 322 static const std::string& GetBrand(); | 304 static const std::string& GetBrand(); |
| 323 | 305 |
| 324 private: | 306 private: |
| 325 ScopedRlzValueStoreLock* lock_; | 307 ScopedRlzValueStoreLock* lock_; |
| 326 }; | 308 }; |
| 327 | 309 |
| 328 } // namespace rlz_lib | 310 } // namespace rlz_lib |
| 329 | 311 |
| 330 #endif // RLZ_LIB_RLZ_LIB_H_ | 312 #endif // RLZ_LIB_RLZ_LIB_H_ |
| OLD | NEW |