Skip to content

Commit

Permalink
Revert 223894 "Revert "Enable device discovery notifications.""
Browse files Browse the repository at this point in the history
Re-enable device discovery. It should not regress perf after r224052.

> Revert "Enable device discovery notifications."
> 
> This reverts commit 15e19ed. This commit is
> being reverted since it causes a significant increase in memory usage.
> 
> TBR=vitalybuka
> BUG=292754
> 
> Review URL: https://codereview.chromium.org/23536066

TBR=teravest@chromium.org

Review URL: https://codereview.chromium.org/24191003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224162 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
vitalybuka@chromium.org committed Sep 19, 2013
1 parent 5b2bacc commit 9486892
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 15 deletions.
6 changes: 6 additions & 0 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -5471,6 +5471,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_DESCRIPTION" desc="Description for 'disable device discovery' flag.">
Disable device discovery on local network.
</message>
<message name="IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NOTIFICATIONS_NAME" desc="Title of the disable 'disable device discovery notificatios' flag.">
Disable Device Discovery Notifications
</message>
<message name="IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NOTIFICATIONS_DESCRIPTION" desc="Description for 'disable device discovery notifications' flag.">
Disable device discovery notifications on local network.
</message>
<message name="IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME" desc="Title of the touch-optimized UI flag." >
Touch Optimized UI
</message>
Expand Down
9 changes: 9 additions & 0 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1516,13 +1516,22 @@ const Experiment kExperiments[] = {
kOsAll,
SINGLE_VALUE_TYPE(switches::kSyncfsEnableDirectoryOperation),
},
#if defined(ENABLE_MDNS)
{
"disable-device-discovery",
IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NAME,
IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_DESCRIPTION,
kOsWin | kOsLinux | kOsCrOS,
SINGLE_VALUE_TYPE(switches::kDisableDeviceDiscovery)
},
{
"disable-device-discovery-notifications",
IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NOTIFICATIONS_NAME,
IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NOTIFICATIONS_DESCRIPTION,
kOsWin | kOsLinux | kOsCrOS,
SINGLE_VALUE_TYPE(switches::kDisableDeviceDiscoveryNotifications)
},
#endif // ENABLE_MDNS
#if defined(OS_MACOSX)
{
"enable-app-shims",
Expand Down
13 changes: 7 additions & 6 deletions chrome/browser/local_discovery/privet_notifications.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/message_loop/message_loop.h"
#include "base/rand_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/local_discovery/privet_device_lister_impl.h"
#include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h"
#include "chrome/browser/local_discovery/privet_traffic_detector.h"
Expand Down Expand Up @@ -152,10 +153,8 @@ PrivetNotificationsListener::DeviceContext::~DeviceContext() {
}

PrivetNotificationService::PrivetNotificationService(
content::BrowserContext* profile,
NotificationUIManager* notification_manager)
: profile_(profile),
notification_manager_(notification_manager) {
content::BrowserContext* profile)
: profile_(profile) {
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&PrivetNotificationService::Start, AsWeakPtr()),
Expand Down Expand Up @@ -213,13 +212,15 @@ void PrivetNotificationService::PrivetNotify(
rich_notification_data,
new PrivetNotificationDelegate(device_name, profile_));

notification_manager_->Add(notification, profile_object);
g_browser_process->notification_ui_manager()->Add(notification,
profile_object);
}
}

void PrivetNotificationService::PrivetRemoveNotification(
const std::string& device_name) {
notification_manager_->CancelById(kPrivetNotificationIDPrefix + device_name);
g_browser_process->notification_ui_manager()->CancelById(
kPrivetNotificationIDPrefix + device_name);
}

void PrivetNotificationService::Start() {
Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/local_discovery/privet_notifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ class PrivetNotificationService
public PrivetNotificationsListener::Delegate,
public base::SupportsWeakPtr<PrivetNotificationService> {
public:
PrivetNotificationService(content::BrowserContext* profile,
NotificationUIManager* notification_manager);
explicit PrivetNotificationService(content::BrowserContext* profile);
virtual ~PrivetNotificationService();

// PrivetDeviceLister::Delegate implementation:
Expand All @@ -117,7 +116,6 @@ class PrivetNotificationService
void StartLister();

content::BrowserContext* profile_;
NotificationUIManager* notification_manager_;
scoped_ptr<PrivetDeviceLister> device_lister_;
scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_;
scoped_refptr<PrivetTrafficDetector> traffic_detector_v4_;
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/local_discovery/privet_notifications_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ PrivetNotificationServiceFactory::~PrivetNotificationServiceFactory() {
BrowserContextKeyedService*
PrivetNotificationServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
return new PrivetNotificationService(
profile, g_browser_process->notification_ui_manager());
return new PrivetNotificationService(profile);
}

bool
PrivetNotificationServiceFactory::ServiceIsCreatedWithBrowserContext() const {
// TODO(vitalybuka): re-enable after fixing broken tests.
return false;
return !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableDeviceDiscovery);
CommandLine* command_line = CommandLine::ForCurrentProcess();
using switches::kDisableDeviceDiscovery;
using switches::kDisableDeviceDiscoveryNotifications;
return !command_line->HasSwitch(kDisableDeviceDiscovery) &&
!command_line->HasSwitch(kDisableDeviceDiscoveryNotifications);
}

bool PrivetNotificationServiceFactory::ServiceIsNULLWhileTesting() const {
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/task_manager/task_manager_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class TaskManagerBrowserTest : public ExtensionBrowserTest {
// well defined.
command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch);
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);

// Do not launch device discovery process.
command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications);
}

private:
Expand Down
4 changes: 4 additions & 0 deletions chrome/common/chrome_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ const char kDisableDefaultApps[] = "disable-default-apps";
// Disables device discovery.
const char kDisableDeviceDiscovery[] = "disable-device-discovery";

// Disables device discovery notifications.
const char kDisableDeviceDiscoveryNotifications[] =
"disable-device-discovery-notifications";

// Disables retrieval of PAC URLs from DHCP as per the WPAD standard.
const char kDisableDhcpWpad[] = "disable-dhcp-wpad";

Expand Down
1 change: 1 addition & 0 deletions chrome/common/chrome_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ extern const char kDisableCRLSets[];
extern const char kDisableCustomJumpList[];
extern const char kDisableDefaultApps[];
extern const char kDisableDeviceDiscovery[];
extern const char kDisableDeviceDiscoveryNotifications[];
extern const char kDisableDhcpWpad[];
extern const char kDisableDnsProbes[];
extern const char kDisableExtensionsFileAccessCheck[];
Expand Down
3 changes: 3 additions & 0 deletions chrome_frame/test/net/fake_external_tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ void FakeExternalTab::Initialize() {
ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);

CommandLine* cmd = CommandLine::ForCurrentProcess();
// Disable Device Discovery with switch because this test does not respect
// BrowserContextKeyedBaseFactory::ServiceIsNULLWhileTesting.
cmd->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications);
cmd->AppendSwitch(switches::kDisableWebResources);
cmd->AppendSwitch(switches::kSingleProcess);

Expand Down

0 comments on commit 9486892

Please sign in to comment.