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

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 149343: http://codereview.chromium.org/147084... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 5
6 6
7 //------------------------------------------------------------------------------ 7 //------------------------------------------------------------------------------
8 // Description of the life cycle of a instance of MetricsService. 8 // Description of the life cycle of a instance of MetricsService.
9 // 9 //
10 // OVERVIEW 10 // OVERVIEW
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 #if defined(OS_WIN) 160 #if defined(OS_WIN)
161 #include <windows.h> 161 #include <windows.h>
162 #include <objbase.h> 162 #include <objbase.h>
163 #endif 163 #endif
164 164
165 #include "base/file_path.h" 165 #include "base/file_path.h"
166 #include "base/histogram.h" 166 #include "base/histogram.h"
167 #include "base/path_service.h" 167 #include "base/path_service.h"
168 #include "base/platform_thread.h" 168 #include "base/platform_thread.h"
169 #include "base/rand_util.h"
169 #include "base/string_util.h" 170 #include "base/string_util.h"
170 #include "base/task.h" 171 #include "base/task.h"
171 #include "chrome/browser/bookmarks/bookmark_model.h" 172 #include "chrome/browser/bookmarks/bookmark_model.h"
172 #include "chrome/browser/browser.h" 173 #include "chrome/browser/browser.h"
173 #include "chrome/browser/browser_list.h" 174 #include "chrome/browser/browser_list.h"
174 #include "chrome/browser/browser_process.h" 175 #include "chrome/browser/browser_process.h"
175 #include "chrome/browser/load_notification_details.h" 176 #include "chrome/browser/load_notification_details.h"
176 #include "chrome/browser/memory_details.h" 177 #include "chrome/browser/memory_details.h"
177 #include "chrome/browser/plugin_service.h" 178 #include "chrome/browser/plugin_service.h"
178 #include "chrome/browser/profile.h" 179 #include "chrome/browser/profile.h"
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 GUID guid; 756 GUID guid;
756 HRESULT guid_result = CoCreateGuid(&guid); 757 HRESULT guid_result = CoCreateGuid(&guid);
757 DCHECK(SUCCEEDED(guid_result)); 758 DCHECK(SUCCEEDED(guid_result));
758 759
759 std::wstring guid_string; 760 std::wstring guid_string;
760 int result = StringFromGUID2(guid, 761 int result = StringFromGUID2(guid,
761 WriteInto(&guid_string, kGUIDSize), kGUIDSize); 762 WriteInto(&guid_string, kGUIDSize), kGUIDSize);
762 DCHECK(result == kGUIDSize); 763 DCHECK(result == kGUIDSize);
763 764
764 return WideToUTF8(guid_string.substr(1, guid_string.length() - 2)); 765 return WideToUTF8(guid_string.substr(1, guid_string.length() - 2));
766 #elif defined(LINUX2)
767 uint64 sixteen_bytes[2] = { base::RandUint64(), base::RandUint64() };
768 return RandomBytesToGUIDString(sixteen_bytes);
765 #else 769 #else
766 // TODO(port): Implement for Mac and linux. 770 // TODO(cmasone): enable the above for all OS_POSIX platforms once the
767 // Rather than actually implementing a random source, might this be a good 771 // first-run dialog text is all up to date.
768 // time to implement http://code.google.com/p/chromium/issues/detail?id=2278
769 // ? I think so!
770 NOTIMPLEMENTED(); 772 NOTIMPLEMENTED();
771 return std::string(); 773 return std::string();
772 #endif 774 #endif
773 } 775 }
774 776
777 #if defined(OS_POSIX)
778 // TODO(cmasone): Once we're comfortable this works, migrate Windows code to
779 // use this as well.
780 std::string MetricsService::RandomBytesToGUIDString(const uint64 bytes[2]) {
781 return StringPrintf("%08llX-%04llX-%04llX-%04llX-%012llX",
782 bytes[0] >> 32,
783 (bytes[0] >> 16) & 0x0000ffff,
784 bytes[0] & 0x0000ffff,
785 bytes[1] >> 48,
786 bytes[1] & 0x0000ffffffffffffULL);
787 }
788 #endif
775 789
776 //------------------------------------------------------------------------------ 790 //------------------------------------------------------------------------------
777 // State save methods 791 // State save methods
778 792
779 void MetricsService::ScheduleNextStateSave() { 793 void MetricsService::ScheduleNextStateSave() {
780 state_saver_factory_.RevokeAll(); 794 state_saver_factory_.RevokeAll();
781 795
782 MessageLoop::current()->PostDelayedTask(FROM_HERE, 796 MessageLoop::current()->PostDelayedTask(FROM_HERE,
783 state_saver_factory_.NewRunnableMethod(&MetricsService::SaveLocalState), 797 state_saver_factory_.NewRunnableMethod(&MetricsService::SaveLocalState),
784 kSaveStateInterval * 1000); 798 kSaveStateInterval * 1000);
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 L"." + key; 1921 L"." + key;
1908 prof_prefs->SetInteger(pref_key.c_str(), value); 1922 prof_prefs->SetInteger(pref_key.c_str(), value);
1909 } 1923 }
1910 1924
1911 static bool IsSingleThreaded() { 1925 static bool IsSingleThreaded() {
1912 static PlatformThreadId thread_id = 0; 1926 static PlatformThreadId thread_id = 0;
1913 if (!thread_id) 1927 if (!thread_id)
1914 thread_id = PlatformThread::CurrentId(); 1928 thread_id = PlatformThread::CurrentId();
1915 return PlatformThread::CurrentId() == thread_id; 1929 return PlatformThread::CurrentId() == thread_id;
1916 } 1930 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/browser/metrics/metrics_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698