Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: chrome/browser/geolocation/wifi_data_provider_common.cc

Issue 553069: Revert 37009 - Adding geolocation data provider infrastructure to Chrome.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2008, Google Inc.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
5 //
6 // 1. Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright notice,
9 // this list of conditions and the following disclaimer in the documentation
10 // and/or other materials provided with the distribution.
11 // 3. Neither the name of Google Inc. nor the names of its contributors may be
12 // used to endorse or promote products derived from this software without
13 // specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 #include "gears/geolocation/wifi_data_provider_common.h"
27
28 #include <assert.h>
29
30 #if defined(WIN32) || defined(OS_MACOSX)
31
32 #if defined(WIN32)
33 #include <windows.h>
34 #elif defined(OS_MACOSX)
35 #include <CoreFoundation/CoreFoundation.h>
36 #include "gears/base/common/string_utils_osx.h"
37 #include "gears/base/safari/scoped_cf.h"
38 #include "third_party/scoped_ptr/scoped_ptr.h" // For scoped_array
39 #endif
40
41 std::string16 MacAddressAsString16(const uint8 mac_as_int[6]) {
42 // mac_as_int is big-endian. Write in byte chunks.
43 // Format is XX-XX-XX-XX-XX-XX.
44 static const char16 *kMacFormatString =
45 STRING16(L"%02x-%02x-%02x-%02x-%02x-%02x");
46 #ifdef OS_MACOSX
47 scoped_cftype<CFStringRef> format_string(CFStringCreateWithCharacters(
48 kCFAllocatorDefault,
49 kMacFormatString,
50 std::char_traits<char16>::length(kMacFormatString)));
51 scoped_cftype<CFStringRef> mac_string(CFStringCreateWithFormat(
52 kCFAllocatorDefault,
53 NULL, // not implemented
54 format_string.get(),
55 mac_as_int[0], mac_as_int[1], mac_as_int[2],
56 mac_as_int[3], mac_as_int[4], mac_as_int[5]));
57 std::string16 mac;
58 CFStringRefToString16(mac_string.get(), &mac);
59 return mac;
60 #else
61 char16 mac[18];
62 #ifdef DEBUG
63 int num_characters =
64 #endif
65 wsprintf(mac, kMacFormatString,
66 mac_as_int[0], mac_as_int[1], mac_as_int[2],
67 mac_as_int[3], mac_as_int[4], mac_as_int[5]);
68 assert(num_characters == 17);
69 return mac;
70 #endif
71 }
72
73 #endif // WIN32 || OS_MACOSX
74
75 #if defined(WIN32) || defined(OS_MACOSX) || defined(LINUX)
76
77 // These constants are defined for each platfrom in wifi_data_provider_xxx.cc.
78 extern const int kDefaultPollingInterval;
79 extern const int kNoChangePollingInterval;
80 extern const int kTwoNoChangePollingInterval;
81
82 int UpdatePollingInterval(int polling_interval, bool scan_results_differ) {
83 if (scan_results_differ) {
84 return kDefaultPollingInterval;
85 }
86 if (polling_interval == kDefaultPollingInterval) {
87 return kNoChangePollingInterval;
88 } else {
89 assert(polling_interval == kNoChangePollingInterval ||
90 polling_interval == kTwoNoChangePollingInterval);
91 return kTwoNoChangePollingInterval;
92 }
93 }
94
95 #endif // WIN32 || OS_MACOSX || LINUX
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/wifi_data_provider_common.h ('k') | chrome/browser/geolocation/wifi_data_provider_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698