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

Side by Side Diff: chromeos/ime/ibus_daemon_controller.cc

Issue 67923002: Fixes for -Wunused-function on Linux, Android and ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase for realz Created 7 years, 1 month 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
« no previous file with comments | « chromeos/dbus/fake_shill_service_client.cc ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chromeos/ime/ibus_daemon_controller.h" 5 #include "chromeos/ime/ibus_daemon_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_path_watcher.h" 9 #include "base/files/file_path_watcher.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
14 14
15 namespace chromeos { 15 namespace chromeos {
16 16
17 namespace { 17 namespace {
18 18
19 IBusDaemonController* g_ibus_daemon_controller = NULL; 19 IBusDaemonController* g_ibus_daemon_controller = NULL;
20 base::FilePathWatcher* g_file_path_watcher = NULL;
21
22 // Called when the ibus-daemon address file is modified.
23 static void OnFilePathChanged(
24 const scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
25 const base::Closure& closure,
26 const base::FilePath& file_path,
27 bool failed) {
28 if (failed)
29 return; // Can't recover, do nothing.
30 if (!g_file_path_watcher)
31 return; // Already discarded watch task.
32
33 ui_task_runner->PostTask(FROM_HERE, closure);
34 ui_task_runner->DeleteSoon(FROM_HERE, g_file_path_watcher);
35 g_file_path_watcher = NULL;
36 }
37
38 // Start watching |address_file_path|. If the target file is changed, |callback|
39 // is called on UI thread. This function should be called on FILE thread.
40 void StartWatch(
41 const std::string& address_file_path,
42 const base::Closure& closure,
43 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner) {
44 // Before start watching, discard on-going watching task.
45 delete g_file_path_watcher;
46 g_file_path_watcher = new base::FilePathWatcher;
47 bool result = g_file_path_watcher->Watch(
48 base::FilePath::FromUTF8Unsafe(address_file_path),
49 false, // do not watch child directory.
50 base::Bind(&OnFilePathChanged,
51 ui_task_runner,
52 closure));
53 DCHECK(result);
54 }
55 20
56 // An implementation of IBusDaemonController without ibus-daemon interaction. 21 // An implementation of IBusDaemonController without ibus-daemon interaction.
57 // Currently this class is used only on linux desktop. 22 // Currently this class is used only on linux desktop.
58 // TODO(nona): Remove IBusDaemonControlelr this once crbug.com/171351 is fixed. 23 // TODO(nona): Remove IBusDaemonControlelr this once crbug.com/171351 is fixed.
59 class IBusDaemonControllerDaemonlessImpl : public IBusDaemonController { 24 class IBusDaemonControllerDaemonlessImpl : public IBusDaemonController {
60 public: 25 public:
61 IBusDaemonControllerDaemonlessImpl() 26 IBusDaemonControllerDaemonlessImpl()
62 : is_started_(false) {} 27 : is_started_(false) {}
63 virtual ~IBusDaemonControllerDaemonlessImpl() {} 28 virtual ~IBusDaemonControllerDaemonlessImpl() {}
64 29
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 delete g_ibus_daemon_controller; 98 delete g_ibus_daemon_controller;
134 g_ibus_daemon_controller = NULL; 99 g_ibus_daemon_controller = NULL;
135 } 100 }
136 101
137 // static 102 // static
138 IBusDaemonController* IBusDaemonController::GetInstance() { 103 IBusDaemonController* IBusDaemonController::GetInstance() {
139 return g_ibus_daemon_controller; 104 return g_ibus_daemon_controller;
140 } 105 }
141 106
142 } // namespace chromeos 107 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_shill_service_client.cc ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698