diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 01:10:45 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 01:10:45 +0000 |
commit | b4037d13ad107e6fc72e1149ed4f760e08aedd9a (patch) | |
tree | 370e5a60e694bab5d7e6dc04010c5c2a966fd6d0 /chrome/browser/chromeos/usb_mount_observer.h | |
parent | e896a4d2af4d4c15aeeeb66fb2b18950f777f103 (diff) | |
download | chromium_src-b4037d13ad107e6fc72e1149ed4f760e08aedd9a.zip chromium_src-b4037d13ad107e6fc72e1149ed4f760e08aedd9a.tar.gz chromium_src-b4037d13ad107e6fc72e1149ed4f760e08aedd9a.tar.bz2 |
Lands http://codereview.chromium.org/379007 for Dave:
Fixes leak in BackingStore as shown by valgrind. XFree doesn't free
the data of the image, where as XDestroyImage does.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/391008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/usb_mount_observer.h')
-rw-r--r-- | chrome/browser/chromeos/usb_mount_observer.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/usb_mount_observer.h b/chrome/browser/chromeos/usb_mount_observer.h new file mode 100644 index 0000000..c6cb2b9 --- /dev/null +++ b/chrome/browser/chromeos/usb_mount_observer.h @@ -0,0 +1,61 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_USB_MOUNT_OBSERVER_H_ +#define CHROME_BROWSER_CHROMEOS_USB_MOUNT_OBSERVER_H_ + +#include <string> +#include <vector> + +#include "chrome/browser/chromeos/mount_library.h" +#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_source.h" +#include "chrome/common/notification_type.h" +#include "chrome/common/notification_registrar.h" + +class Browser; +class Profile; + +namespace chromeos { // NOLINT + +// Used to monitor mount changes and popup a new window when +// a new mounted usb device is found. +class USBMountObserver : public chromeos::MountLibrary::Observer, + public NotificationObserver { + public: + struct BrowserWithPath { + Browser* browser; + std::string device_path; + }; + + USBMountObserver() {} + ~USBMountObserver() {} + + void set_profile(Profile* profile) { profile_ = profile; } + + static USBMountObserver* Get() { + return Singleton<USBMountObserver>::get(); + } + void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + void MountChanged(chromeos::MountLibrary* obj, + chromeos::MountEventType evt, + const std::string& path); + private: + typedef std::vector<BrowserWithPath>::iterator BrowserIterator; + BrowserIterator FindBrowserForPath(const std::string& path); + + void RemoveBrowserFromVector(const std::string& path); + + Profile* profile_; + std::vector<BrowserWithPath> browsers_; + NotificationRegistrar registrar_; + + DISALLOW_COPY_AND_ASSIGN(USBMountObserver); +}; + +} // namespace chromeos +#endif // CHROME_BROWSER_CHROMEOS_USB_MOUNT_OBSERVER_H_ |