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

Side by Side Diff: chrome/browser/background/background_mode_manager.cc

Issue 2767893002: Remove ScopedVector from chrome/browser/. (Closed)
Patch Set: Address comments from zea@ Created 3 years, 8 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 (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/background/background_mode_manager.h" 5 #include "chrome/browser/background/background_mode_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/base_paths.h" 13 #include "base/base_paths.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/location.h" 17 #include "base/location.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/ptr_util.h"
19 #include "base/metrics/histogram_macros.h" 20 #include "base/metrics/histogram_macros.h"
20 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread_task_runner_handle.h" 23 #include "base/threading/thread_task_runner_handle.h"
23 #include "build/build_config.h" 24 #include "build/build_config.h"
24 #include "chrome/app/chrome_command_ids.h" 25 #include "chrome/app/chrome_command_ids.h"
25 #include "chrome/browser/background/background_application_list_model.h" 26 #include "chrome/browser/background/background_application_list_model.h"
26 #include "chrome/browser/background/background_mode_optimizer.h" 27 #include "chrome/browser/background/background_mode_optimizer.h"
27 #include "chrome/browser/background/background_trigger.h" 28 #include "chrome/browser/background/background_trigger.h"
28 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 std::vector<BackgroundModeData*> bmd_vector; 969 std::vector<BackgroundModeData*> bmd_vector;
969 for (const auto& it : background_mode_data_) 970 for (const auto& it : background_mode_data_)
970 bmd_vector.push_back(it.second.get()); 971 bmd_vector.push_back(it.second.get());
971 std::sort(bmd_vector.begin(), bmd_vector.end(), 972 std::sort(bmd_vector.begin(), bmd_vector.end(),
972 &BackgroundModeData::BackgroundModeDataCompare); 973 &BackgroundModeData::BackgroundModeDataCompare);
973 int profiles_using_background_mode = 0; 974 int profiles_using_background_mode = 0;
974 for (auto* bmd : bmd_vector) { 975 for (auto* bmd : bmd_vector) {
975 // We should only display the profile in the status icon if it has at 976 // We should only display the profile in the status icon if it has at
976 // least one background app. 977 // least one background app.
977 if (bmd->GetBackgroundClientCount() > 0) { 978 if (bmd->GetBackgroundClientCount() > 0) {
978 StatusIconMenuModel* submenu = new StatusIconMenuModel(bmd);
979 // The submenu constructor caller owns the lifetime of the submenu. 979 // The submenu constructor caller owns the lifetime of the submenu.
980 // The containing menu does not handle the lifetime. 980 // The containing menu does not handle the lifetime.
981 submenus.push_back(submenu); 981 submenus.push_back(base::MakeUnique<StatusIconMenuModel>(bmd));
982 bmd->BuildProfileMenu(submenu, menu.get()); 982 bmd->BuildProfileMenu(submenus.back().get(), menu.get());
983 profiles_using_background_mode++; 983 profiles_using_background_mode++;
984 } 984 }
985 } 985 }
986 // We should only be displaying the status tray icon if there is at least 986 // We should only be displaying the status tray icon if there is at least
987 // one profile using background mode. If |keep_alive_for_test_| is set, 987 // one profile using background mode. If |keep_alive_for_test_| is set,
988 // there may not be any profiles and that is okay. 988 // there may not be any profiles and that is okay.
989 DCHECK(profiles_using_background_mode > 0 || keep_alive_for_test_); 989 DCHECK(profiles_using_background_mode > 0 || keep_alive_for_test_);
990 } else { 990 } else {
991 // We should only have one profile in the ProfileAttributesStorage if we are 991 // We should only have one profile in the ProfileAttributesStorage if we are
992 // not using multi-profiles. If |keep_alive_for_test_| is set, then we may 992 // not using multi-profiles. If |keep_alive_for_test_| is set, then we may
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 } 1047 }
1048 } 1048 }
1049 return profile_it; 1049 return profile_it;
1050 } 1050 }
1051 1051
1052 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { 1052 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const {
1053 PrefService* service = g_browser_process->local_state(); 1053 PrefService* service = g_browser_process->local_state();
1054 DCHECK(service); 1054 DCHECK(service);
1055 return service->GetBoolean(prefs::kBackgroundModeEnabled); 1055 return service->GetBoolean(prefs::kBackgroundModeEnabled);
1056 } 1056 }
OLDNEW
« no previous file with comments | « chrome/browser/background/background_mode_manager.h ('k') | chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698