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

Side by Side Diff: chrome/browser/speech/tab_watcher.h

Issue 10663018: Changing tab closure handling logic in speech recognition code and cleaning bubble controller. (Spe… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SPEECH_TAB_WATCHER_H_
6 #define CHROME_BROWSER_SPEECH_TAB_WATCHER_H_
7 #pragma once
8
9 #include <set>
10
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/notification_observer.h"
16
17 namespace content {
18 class NotificationRegistrar;
19 class WebContents;
20 }
21
22 // Simple utility class that allows to watch for tabs (or more precisely,
23 // WebContents in general) closure, being notified by a callback on a custom
24 // thread. Both the callback site and the callback thread are defined by the
25 // caller in the constructor.
26 // There is no restriction on the constructor, however this class must be
27 // destroyed on the UI thread, due to the NotificationRegistrar dependency.
hans 2012/06/26 13:10:44 i wonder if the description could be shorted a lit
Primiano Tucci (use gerrit) 2012/06/26 14:27:07 Done.
28 class TabWatcher
29 : public base::RefCountedThreadSafe<TabWatcher>,
hans 2012/06/26 13:10:44 looks like some extra space between the : and the
Primiano Tucci (use gerrit) 2012/06/26 14:27:07 Done.
30 public content::NotificationObserver {
31 public:
32 typedef base::Callback<void(int render_process_id, int render_view_id)>
33 TabClosedCallback;
34
35 TabWatcher(TabClosedCallback tab_closed_callback,
36 content::BrowserThread::ID callback_thread);
37
38 void Watch(int render_process_id, int render_view_id);
39
40 private:
41 friend class base::RefCountedThreadSafe<TabWatcher>;
42
43 static void AbortAllSessionsForWebContentOnIOThread(int render_process_id,
hans 2012/06/26 13:10:44 what does this do? what's a session in the context
Primiano Tucci (use gerrit) 2012/06/26 14:27:07 Ops, I guess it was just a too large copy/paste, w
44 int render_view_id);
45 virtual ~TabWatcher();
46
47 // content::NotificationObserver implementation.
48 virtual void Observe(int type,
49 const content::NotificationSource& source,
50 const content::NotificationDetails& details) OVERRIDE;
51
52 // Lazy-initialized and used in the UI thread to handle web contents
53 // notifications (tab closing).
54 scoped_ptr<content::NotificationRegistrar> registrar_;
55
56 // Keeps track of which WebContent(s) have been registered, in order to avoid
57 // double registrations on |registrar_|
58 std::set<content::WebContents*> registered_contents_;
59
60 // Callback used to notify, on the thread specified by |callback_thread_| the
61 // closure of a registered tab.
62 TabClosedCallback tab_closed_callback_;
63 content::BrowserThread::ID callback_thread_;
64
65 DISALLOW_COPY_AND_ASSIGN(TabWatcher);
66 };
67
68 #endif // CHROME_BROWSER_SPEECH_TAB_WATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698