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

Side by Side Diff: chrome/browser/sync/util/get_session_name_task.h

Issue 9565050: [Sync] Simplify GetSessionName interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile failure Created 8 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SYNC_UTIL_GET_SESSION_NAME_TASK_H_
6 #define CHROME_BROWSER_SYNC_UTIL_GET_SESSION_NAME_TASK_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h"
15
16 namespace base {
17 class MessageLoopProxy;
18 } // namespace base
19
20 namespace browser_sync {
21
22 class GetSessionNameTask
23 : public base::RefCountedThreadSafe<GetSessionNameTask> {
24 public:
25 typedef base::Callback<void(const std::string& name)>
26 OnSessionNameInitialized;
27
28 explicit GetSessionNameTask(const OnSessionNameInitialized& callback);
29 virtual ~GetSessionNameTask();
30
31 void GetSessionNameAsync();
32
33 private:
34 friend class base::RefCountedThreadSafe<GetSessionNameTask>;
35
36 FRIEND_TEST_ALL_PREFIXES(SyncGetSessionNameTaskTest, GetHardwareModelName);
37 FRIEND_TEST_ALL_PREFIXES(SyncGetSessionNameTaskTest, GetComputerName);
38
39 void InvokeCallback(const std::string& session_name);
40
41 #if defined(OS_MACOSX)
42 // Returns the Hardware model name, without trailing numbers, if possible.
43 // See http://www.cocoadev.com/index.pl?MacintoshModels for an example list of
44 // models. If an error occurs trying to read the model, this simply returns
45 // "Unknown".
46 static std::string GetHardwareModelName();
47 #endif
48
49 #if defined(OS_WIN)
50 // Returns the computer name or the empty string if an error occured.
51 static std::string GetComputerName();
52 #endif
53
54 const OnSessionNameInitialized callback_;
55 const scoped_refptr<base::MessageLoopProxy> thread_;
56
57 DISALLOW_COPY_AND_ASSIGN(GetSessionNameTask);
58 };
59
60 } // namespace browser_sync
61
62 #endif // CHROME_BROWSER_SYNC_UTIL_GET_SESSION_NAME_TASK_H__
OLDNEW
« no previous file with comments | « chrome/browser/sync/util/get_session_name_mac.mm ('k') | chrome/browser/sync/util/get_session_name_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698