Skip to content

Commit

Permalink
Add undeclared virtual destructors part 2
Browse files Browse the repository at this point in the history
Preventative maintainance for abstract classes that do not declare virtual destructors. Base classes that do not declare their destructors as virtual could potentially lead to memory leaks.

r=jar 
BUG=47469



Review URL: http://codereview.chromium.org/3032024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53831 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ziadh@chromium.org committed Jul 27, 2010
1 parent 28a5e7b commit c12ecab
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 8 deletions.
3 changes: 3 additions & 0 deletions app/active_window_watcher_x.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class ActiveWindowWatcherX {
public:
// |active_window| will be NULL if the active window isn't one of Chrome's.
virtual void ActiveWindowChanged(GdkWindow* active_window) = 0;

protected:
virtual ~Observer() {}
};

static void AddObserver(Observer* observer);
Expand Down
3 changes: 3 additions & 0 deletions app/menus/button_menu_item_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class ButtonMenuItemModel {
// Performs the action associated with the specified command id.
virtual void ExecuteCommand(int command_id) = 0;
virtual bool IsCommandIdEnabled(int command_id) const { return true; }

protected:
virtual ~Delegate() {}
};

ButtonMenuItemModel(int string_id, ButtonMenuItemModel::Delegate* delegate);
Expand Down
3 changes: 3 additions & 0 deletions chrome/common/deprecated/event_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ template <typename EventType>
class EventListener {
public:
virtual void HandleEvent(const EventType& event) = 0;

protected:
virtual ~EventListener() {}
};

// See the -inl.h for details about the following.
Expand Down
3 changes: 3 additions & 0 deletions chrome/common/mach_message_source_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class MachMessageSource {
class MachPortListener {
public:
virtual void OnMachMessageReceived(void* mach_msg, size_t size) = 0;

protected:
virtual ~OnMachMessageReceived() {}
};

// |listener| is a week reference passed to CF, it needs to remain in
Expand Down
2 changes: 2 additions & 0 deletions chrome/common/sandbox_mac_unittest_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class MacSandboxTest : public MultiProcessTest {
// REGISTER_SANDBOX_TEST_CASE so it's visible to the test driver.
class MacSandboxTestCase {
public:
virtual ~MacSandboxTestCase() {}

// Code that runs in the sandboxed subprocess before the sandbox is
// initialized.
// Returning false from this function will cause the entire test case to fail.
Expand Down
6 changes: 5 additions & 1 deletion chrome/installer/util/html_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ class HTMLDialog {
// The native window has been created and is about to be visible. Use it
// to customize the native |window| appearance.
virtual void OnBeforeDisplay(void* window) = 0;

protected:
virtual ~CustomizationCallback() {}
};

virtual ~HTMLDialog() {}

// Shows the HTML in a modal dialog. The buttons and other UI are also done
// in HTML so each native implementation needs to map the user action into
// one of the 6 possible results of DialogResult. Important, call this
Expand All @@ -51,7 +56,6 @@ class HTMLDialog {
// If the result of ShowModal() was EXTRA, the information is available
// as a string using this method.
virtual std::wstring GetExtraResult() = 0;

};

// Factory method for the native HTML Dialog. When done with the object use
Expand Down
2 changes: 1 addition & 1 deletion chrome/renderer/pepper_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PepperWidget {
virtual void SetProperty(NPWidgetProperty property, void* value) = 0;

protected:
~PepperWidget();
virtual ~PepperWidget();

// Tells the plugin that a property changed.
void WidgetPropertyChanged(NPWidgetProperty property);
Expand Down
2 changes: 1 addition & 1 deletion chrome/renderer/render_view_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RenderViewVisitor {
virtual bool Visit(RenderView* render_view) = 0;

protected:
~RenderViewVisitor() {}
virtual ~RenderViewVisitor() {}
};

#endif // CHROME_RENDERER_RENDER_VIEW_VISITOR_H_
3 changes: 3 additions & 0 deletions chrome/service/cloud_print/job_status_updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class JobStatusUpdater : public base::RefCountedThreadSafe<JobStatusUpdater>,
class Delegate {
public:
virtual bool OnJobCompleted(JobStatusUpdater* updater) = 0;

protected:
virtual ~Delegate() {}
};

JobStatusUpdater(const std::string& printer_name,
Expand Down
2 changes: 2 additions & 0 deletions chrome/test/interactive_ui/view_event_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class ViewEventTestBase : public views::WindowDelegate,
static bool ImplementsThreadSafeReferenceCounting() { return false; }

protected:
virtual ~ViewEventTestBase() {}

// Returns the view that is added to the window.
virtual views::View* CreateContentsView() = 0;

Expand Down
13 changes: 8 additions & 5 deletions chrome_frame/np_event_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ class NpEventListener {
virtual bool Unsubscribe(NPP instance,
const char* event_names[],
int event_name_count) = 0;

protected:
virtual ~NpEventListener() {}
};

// A little helper class to implement simple ref counting
// and assert on single threadedness.
template <class T>
class NpEventListenerBase : public NpEventListener {
public:
NpEventListenerBase(NpEventDelegate* delegate)
explicit NpEventListenerBase(NpEventDelegate* delegate)
: ref_count_(0), delegate_(delegate) {
DCHECK(delegate_);
thread_id_ = ::GetCurrentThreadId();
Expand Down Expand Up @@ -83,8 +86,8 @@ class DomEventListener
: public nsIDOMEventListener,
public NpEventListenerBase<DomEventListener> {
public:
DomEventListener(NpEventDelegate* delegate);
~DomEventListener();
explicit DomEventListener(NpEventDelegate* delegate);
virtual ~DomEventListener();

// Implementation of NpEventListener
virtual bool Subscribe(NPP instance,
Expand Down Expand Up @@ -118,7 +121,7 @@ class DomEventListener
class NPObjectEventListener
: public NpEventListenerBase<NPObjectEventListener> {
public:
NPObjectEventListener(NpEventDelegate* delegate);
explicit NPObjectEventListener(NpEventDelegate* delegate);
~NPObjectEventListener();

// Implementation of NpEventListener
Expand All @@ -133,7 +136,7 @@ class NPObjectEventListener
// NPObject structure which is exposed by NPObjectEventListener.
class Npo : public NPObject {
public:
Npo(NPP npp) : npp_(npp), listener_(NULL) {
explicit Npo(NPP npp) : npp_(npp), listener_(NULL) {
}

void Initialize(NPObjectEventListener* listener) {
Expand Down
3 changes: 3 additions & 0 deletions chrome_frame/test/window_watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ struct FunctionStub;
class WindowObserver { // NOLINT
public:
virtual void OnWindowDetected(HWND hwnd, const std::string& caption) = 0;

protected:
virtual ~WindowObserver() {}
};

// Watch a for window to be shown with the given window class name.
Expand Down
3 changes: 3 additions & 0 deletions printing/printed_pages_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class PrintedPagesSource {

// Returns the URL's source of the document if applicable.
virtual GURL RenderSourceUrl() = 0;

protected:
virtual ~PrintedPagesSource() {}
};

} // namespace printing
Expand Down
3 changes: 3 additions & 0 deletions views/controls/button/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Event;
class ButtonListener {
public:
virtual void ButtonPressed(Button* sender, const views::Event& event) = 0;

protected:
virtual ~ButtonListener() {}
};

// A View representing a button. Depending on the specific type, the button
Expand Down
3 changes: 3 additions & 0 deletions views/controls/button/native_button_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class NativeButtonWrapper {
static NativeButtonWrapper* CreateCheckboxWrapper(Checkbox* checkbox);
static NativeButtonWrapper* CreateRadioButtonWrapper(
RadioButton* radio_button);

protected:
virtual ~NativeButtonWrapper() {}
};

} // namespace views
Expand Down
3 changes: 3 additions & 0 deletions views/controls/combobox/native_combobox_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class NativeComboboxWrapper {
virtual gfx::NativeView GetTestingHandle() const = 0;

static NativeComboboxWrapper* CreateWrapper(Combobox* combobox);

protected:
virtual ~NativeComboboxWrapper() {}
};

} // namespace views
Expand Down
3 changes: 3 additions & 0 deletions views/controls/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class Link;
class LinkController {
public:
virtual void LinkActivated(Link* source, int event_flags) = 0;

protected:
virtual ~LinkController() {}
};

////////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions views/controls/listbox/native_listbox_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class NativeListboxWrapper {
Listbox* listbox,
const std::vector<string16>& strings,
Listbox::Listener* listener);

protected:
virtual ~NativeListboxWrapper() {}
};

} // namespace views
Expand Down
3 changes: 3 additions & 0 deletions views/controls/menu/view_menu_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class ViewMenuDelegate {
// Create and show a menu at the specified position. Source is the view the
// ViewMenuDelegate was set on.
virtual void RunMenu(View* source, const gfx::Point& pt) = 0;

protected:
virtual ~ViewMenuDelegate() {}
};

} // namespace views
Expand Down
3 changes: 3 additions & 0 deletions views/controls/table/native_table_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class NativeTableWrapper {

// Creates an appropriate NativeButtonWrapper for the platform.
static NativeTableWrapper* CreateNativeWrapper(TableView2* table);

protected:
virtual ~NativeTableWrapper() {}
};

} // namespace views
Expand Down
2 changes: 2 additions & 0 deletions views/views_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace views {
// implementation.
class ViewsDelegate {
public:
virtual ~ViewsDelegate() {}

// Gets the clipboard.
virtual Clipboard* GetClipboard() const = 0;

Expand Down

0 comments on commit c12ecab

Please sign in to comment.