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

Side by Side Diff: ash/system/chromeos/network/network_state_notifier.cc

Issue 14876021: Re-factor network_event_log (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address final nits Created 7 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/system/syslogs_provider.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 "ash/system/chromeos/network/network_state_notifier.h" 5 #include "ash/system/chromeos/network/network_state_notifier.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/chromeos/network/network_observer.h" 9 #include "ash/system/chromeos/network/network_observer.h"
10 #include "ash/system/tray/system_tray_notifier.h" 10 #include "ash/system/tray/system_tray_notifier.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chromeos/network/network_event_log.h" 15 #include "chromeos/network/network_event_log.h"
16 #include "chromeos/network/network_state.h" 16 #include "chromeos/network/network_state.h"
17 #include "chromeos/network/network_state_handler.h" 17 #include "chromeos/network/network_state_handler.h"
18 #include "grit/ash_strings.h" 18 #include "grit/ash_strings.h"
19 #include "third_party/cros_system_api/dbus/service_constants.h" 19 #include "third_party/cros_system_api/dbus/service_constants.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 21
22 using chromeos::NetworkState; 22 using chromeos::NetworkState;
23 using chromeos::NetworkStateHandler; 23 using chromeos::NetworkStateHandler;
24 24
25 namespace { 25 namespace {
26 26
27 const char kLogModule[] = "NetworkStateNotifier";
28
29 const int kMinTimeBetweenOutOfCreditsNotifySeconds = 10 * 60; 27 const int kMinTimeBetweenOutOfCreditsNotifySeconds = 10 * 60;
30 28
31 ash::NetworkObserver::NetworkType GetAshNetworkType( 29 ash::NetworkObserver::NetworkType GetAshNetworkType(
32 const NetworkState* network) { 30 const NetworkState* network) {
33 const std::string& type = network->type(); 31 const std::string& type = network->type();
34 if (type == flimflam::kTypeCellular) { 32 if (type == flimflam::kTypeCellular) {
35 if (network->technology() == flimflam::kNetworkTechnologyLte || 33 if (network->technology() == flimflam::kNetworkTechnologyLte ||
36 network->technology() == flimflam::kNetworkTechnologyLteAdvanced) 34 network->technology() == flimflam::kNetworkTechnologyLteAdvanced)
37 return ash::NetworkObserver::NETWORK_CELLULAR_LTE; 35 return ash::NetworkObserver::NETWORK_CELLULAR_LTE;
38 else 36 else
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 cached_state_[network->path()] = new_state; 149 cached_state_[network->path()] = new_state;
152 return; // New network, no state change 150 return; // New network, no state change
153 } 151 }
154 152
155 if (new_state != flimflam::kStateFailure) 153 if (new_state != flimflam::kStateFailure)
156 return; 154 return;
157 155
158 if (network->path() != handler->connecting_network()) 156 if (network->path() != handler->connecting_network())
159 return; // Only show notifications for explicitly connected networks 157 return; // Only show notifications for explicitly connected networks
160 158
161 chromeos::network_event_log::AddEntry( 159 NET_LOG_EVENT("ConnectionFailure", network->path());
162 kLogModule, "ConnectionFailure", network->path());
163 160
164 std::vector<string16> no_links; 161 std::vector<string16> no_links;
165 ash::NetworkObserver::NetworkType network_type = GetAshNetworkType(network); 162 ash::NetworkObserver::NetworkType network_type = GetAshNetworkType(network);
166 string16 error = GetErrorString(network->error()); 163 string16 error = GetErrorString(network->error());
167 ash::Shell::GetInstance()->system_tray_notifier()->NotifySetNetworkMessage( 164 ash::Shell::GetInstance()->system_tray_notifier()->NotifySetNetworkMessage(
168 this, ash::NetworkObserver::ERROR_CONNECT_FAILED, network_type, 165 this, ash::NetworkObserver::ERROR_CONNECT_FAILED, network_type,
169 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), 166 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE),
170 l10n_util::GetStringFUTF16( 167 l10n_util::GetStringFUTF16(
171 IDS_NETWORK_CONNECTION_ERROR_MESSAGE_WITH_DETAILS, 168 IDS_NETWORK_CONNECTION_ERROR_MESSAGE_WITH_DETAILS,
172 UTF8ToUTF16(network->name()), error), 169 UTF8ToUTF16(network->name()), error),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 cached_state_[network->path()] = network->connection_state(); 231 cached_state_[network->path()] = network->connection_state();
235 } 232 }
236 const NetworkState* default_network = 233 const NetworkState* default_network =
237 NetworkStateHandler::Get()->DefaultNetwork(); 234 NetworkStateHandler::Get()->DefaultNetwork();
238 if (default_network && default_network->IsConnectedState()) 235 if (default_network && default_network->IsConnectedState())
239 last_active_network_ = default_network->path(); 236 last_active_network_ = default_network->path();
240 } 237 }
241 238
242 } // namespace internal 239 } // namespace internal
243 } // namespace ash 240 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/system/syslogs_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698