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

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 1160073004: chrome/browser/ui: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // defined(OS_WIN) 10 #endif // defined(OS_WIN)
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <string> 13 #include <string>
14 14
15 #include "base/base_paths.h" 15 #include "base/base_paths.h"
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/location.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
20 #include "base/prefs/pref_service.h" 21 #include "base/prefs/pref_service.h"
21 #include "base/process/process_info.h" 22 #include "base/process/process_info.h"
22 #include "base/profiler/scoped_tracker.h" 23 #include "base/profiler/scoped_tracker.h"
24 #include "base/single_thread_task_runner.h"
23 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
25 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
26 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
29 #include "base/thread_task_runner_handle.h"
27 #include "base/threading/thread.h" 30 #include "base/threading/thread.h"
28 #include "base/threading/thread_restrictions.h" 31 #include "base/threading/thread_restrictions.h"
29 #include "base/time/time.h" 32 #include "base/time/time.h"
30 #include "chrome/app/chrome_command_ids.h" 33 #include "chrome/app/chrome_command_ids.h"
31 #include "chrome/browser/app_mode/app_mode_utils.h" 34 #include "chrome/browser/app_mode/app_mode_utils.h"
32 #include "chrome/browser/autofill/personal_data_manager_factory.h" 35 #include "chrome/browser/autofill/personal_data_manager_factory.h"
33 #include "chrome/browser/background/background_contents.h" 36 #include "chrome/browser/background/background_contents.h"
34 #include "chrome/browser/background/background_contents_service.h" 37 #include "chrome/browser/background/background_contents_service.h"
35 #include "chrome/browser/background/background_contents_service_factory.h" 38 #include "chrome/browser/background/background_contents_service_factory.h"
36 #include "chrome/browser/browser_process.h" 39 #include "chrome/browser/browser_process.h"
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 } 1156 }
1154 } 1157 }
1155 1158
1156 void Browser::TabStripEmpty() { 1159 void Browser::TabStripEmpty() {
1157 // Close the frame after we return to the message loop (not immediately, 1160 // Close the frame after we return to the message loop (not immediately,
1158 // otherwise it will destroy this object before the stack has a chance to 1161 // otherwise it will destroy this object before the stack has a chance to
1159 // cleanly unwind.) 1162 // cleanly unwind.)
1160 // Note: This will be called several times if TabStripEmpty is called several 1163 // Note: This will be called several times if TabStripEmpty is called several
1161 // times. This is because it does not close the window if tabs are 1164 // times. This is because it does not close the window if tabs are
1162 // still present. 1165 // still present.
1163 base::MessageLoop::current()->PostTask( 1166 base::ThreadTaskRunnerHandle::Get()->PostTask(
1164 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); 1167 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr()));
1165 1168
1166 // Instant may have visible WebContents that need to be detached before the 1169 // Instant may have visible WebContents that need to be detached before the
1167 // window system closes. 1170 // window system closes.
1168 instant_controller_.reset(); 1171 instant_controller_.reset();
1169 } 1172 }
1170 1173
1171 bool Browser::CanOverscrollContent() const { 1174 bool Browser::CanOverscrollContent() const {
1172 #if defined(OS_WIN) 1175 #if defined(OS_WIN)
1173 // Don't enable overscroll on Windows machines unless they have a touch 1176 // Don't enable overscroll on Windows machines unless they have a touch
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 2182
2180 // If the only updates were synchronously handled above, we're done. 2183 // If the only updates were synchronously handled above, we're done.
2181 if (changed_flags == 0) 2184 if (changed_flags == 0)
2182 return; 2185 return;
2183 2186
2184 // Save the dirty bits. 2187 // Save the dirty bits.
2185 scheduled_updates_[source] |= changed_flags; 2188 scheduled_updates_[source] |= changed_flags;
2186 2189
2187 if (!chrome_updater_factory_.HasWeakPtrs()) { 2190 if (!chrome_updater_factory_.HasWeakPtrs()) {
2188 // No task currently scheduled, start another. 2191 // No task currently scheduled, start another.
2189 base::MessageLoop::current()->PostDelayedTask( 2192 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
2190 FROM_HERE, 2193 FROM_HERE, base::Bind(&Browser::ProcessPendingUIUpdates,
2191 base::Bind(&Browser::ProcessPendingUIUpdates, 2194 chrome_updater_factory_.GetWeakPtr()),
2192 chrome_updater_factory_.GetWeakPtr()),
2193 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS)); 2195 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS));
2194 } 2196 }
2195 } 2197 }
2196 2198
2197 void Browser::ProcessPendingUIUpdates() { 2199 void Browser::ProcessPendingUIUpdates() {
2198 #ifndef NDEBUG 2200 #ifndef NDEBUG
2199 // Validate that all tabs we have pending updates for exist. This is scary 2201 // Validate that all tabs we have pending updates for exist. This is scary
2200 // because the pending list must be kept in sync with any detached or 2202 // because the pending list must be kept in sync with any detached or
2201 // deleted tabs. 2203 // deleted tabs.
2202 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); 2204 for (UpdateMap::const_iterator i = scheduled_updates_.begin();
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 if (contents && !allow_js_access) { 2620 if (contents && !allow_js_access) {
2619 contents->web_contents()->GetController().LoadURL( 2621 contents->web_contents()->GetController().LoadURL(
2620 target_url, 2622 target_url,
2621 content::Referrer(), 2623 content::Referrer(),
2622 ui::PAGE_TRANSITION_LINK, 2624 ui::PAGE_TRANSITION_LINK,
2623 std::string()); // No extra headers. 2625 std::string()); // No extra headers.
2624 } 2626 }
2625 2627
2626 return contents != NULL; 2628 return contents != NULL;
2627 } 2629 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698