| 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 #include "chrome/browser/ui/views/status_icons/status_tray_win.h" | 5 #include "chrome/browser/ui/views/status_icons/status_tray_win.h" |
| 6 | 6 |
| 7 #include <commctrl.h> | 7 #include <commctrl.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" |
| 10 #include "base/profiler/scoped_tracker.h" | 11 #include "base/profiler/scoped_tracker.h" |
| 12 #include "base/single_thread_task_runner.h" |
| 11 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 12 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 13 #include "base/win/wrapped_window_proc.h" | 15 #include "base/win/wrapped_window_proc.h" |
| 14 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
| 15 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" | 17 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" |
| 16 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" | 18 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" |
| 17 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
| 18 #include "components/browser_watcher/exit_funnel_win.h" | 20 #include "components/browser_watcher/exit_funnel_win.h" |
| 19 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 20 #include "ui/gfx/win/hwnd_util.h" | 22 #include "ui/gfx/win/hwnd_util.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 weak_factory_(this) { | 71 weak_factory_(this) { |
| 70 worker_thread_.init_com_with_mta(false); | 72 worker_thread_.init_com_with_mta(false); |
| 71 } | 73 } |
| 72 | 74 |
| 73 void EnqueueChange(UINT icon_id, HWND window) override { | 75 void EnqueueChange(UINT icon_id, HWND window) override { |
| 74 DCHECK(CalledOnValidThread()); | 76 DCHECK(CalledOnValidThread()); |
| 75 if (pending_requests_ == 0) | 77 if (pending_requests_ == 0) |
| 76 worker_thread_.Start(); | 78 worker_thread_.Start(); |
| 77 | 79 |
| 78 ++pending_requests_; | 80 ++pending_requests_; |
| 79 worker_thread_.message_loop_proxy()->PostTaskAndReply( | 81 worker_thread_.task_runner()->PostTaskAndReply( |
| 80 FROM_HERE, | 82 FROM_HERE, |
| 81 base::Bind( | 83 base::Bind( |
| 82 &StatusTrayStateChangerProxyImpl::EnqueueChangeOnWorkerThread, | 84 &StatusTrayStateChangerProxyImpl::EnqueueChangeOnWorkerThread, |
| 83 icon_id, | 85 icon_id, window), |
| 84 window), | |
| 85 base::Bind(&StatusTrayStateChangerProxyImpl::ChangeDone, | 86 base::Bind(&StatusTrayStateChangerProxyImpl::ChangeDone, |
| 86 weak_factory_.GetWeakPtr())); | 87 weak_factory_.GetWeakPtr())); |
| 87 } | 88 } |
| 88 | 89 |
| 89 private: | 90 private: |
| 90 // Must be called only on |worker_thread_|, to ensure the correct COM | 91 // Must be called only on |worker_thread_|, to ensure the correct COM |
| 91 // apartment. | 92 // apartment. |
| 92 static void EnqueueChangeOnWorkerThread(UINT icon_id, HWND window) { | 93 static void EnqueueChangeOnWorkerThread(UINT icon_id, HWND window) { |
| 93 // It appears that IUnknowns are coincidentally compatible with | 94 // It appears that IUnknowns are coincidentally compatible with |
| 94 // scoped_refptr. Normally I wouldn't depend on that but it seems that | 95 // scoped_refptr. Normally I wouldn't depend on that but it seems that |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 257 } |
| 257 | 258 |
| 258 void StatusTrayWin::SetStatusTrayStateChangerProxyForTest( | 259 void StatusTrayWin::SetStatusTrayStateChangerProxyForTest( |
| 259 scoped_ptr<StatusTrayStateChangerProxy> proxy) { | 260 scoped_ptr<StatusTrayStateChangerProxy> proxy) { |
| 260 state_changer_proxy_ = proxy.Pass(); | 261 state_changer_proxy_ = proxy.Pass(); |
| 261 } | 262 } |
| 262 | 263 |
| 263 StatusTray* StatusTray::Create() { | 264 StatusTray* StatusTray::Create() { |
| 264 return new StatusTrayWin(); | 265 return new StatusTrayWin(); |
| 265 } | 266 } |
| OLD | NEW |