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

Side by Side Diff: chrome/browser/automation/automation_provider_observers.h

Issue 7544026: Fix for flakiness in pyauto automation hook WaitForDownloadsToComplete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with trunk; awaiting green trybots. Created 9 years, 4 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/automation/automation_provider_observers.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ 5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ 6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <deque> 9 #include <deque>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/values.h"
18 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
19 #include "chrome/browser/automation/automation_provider_json.h" 20 #include "chrome/browser/automation/automation_provider_json.h"
20 #include "chrome/browser/automation/automation_tab_helper.h" 21 #include "chrome/browser/automation/automation_tab_helper.h"
21 #include "chrome/browser/bookmarks/bookmark_model_observer.h" 22 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
22 #include "chrome/browser/browsing_data_remover.h" 23 #include "chrome/browser/browsing_data_remover.h"
23 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/chromeos/cros/network_library.h" 25 #include "chrome/browser/chromeos/cros/network_library.h"
25 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" 26 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h"
26 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h" 27 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h"
27 #include "chrome/browser/chromeos/login/enterprise_enrollment_view.h" 28 #include "chrome/browser/chromeos/login/enterprise_enrollment_view.h"
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 // observer list). 1029 // observer list).
1029 void ReplyAndDelete(bool success); 1030 void ReplyAndDelete(bool success);
1030 1031
1031 base::WeakPtr<AutomationProvider> automation_provider_; 1032 base::WeakPtr<AutomationProvider> automation_provider_;
1032 scoped_ptr<IPC::Message> reply_message_; 1033 scoped_ptr<IPC::Message> reply_message_;
1033 BookmarkModel* model_; 1034 BookmarkModel* model_;
1034 1035
1035 DISALLOW_COPY_AND_ASSIGN(AutomationProviderBookmarkModelObserver); 1036 DISALLOW_COPY_AND_ASSIGN(AutomationProviderBookmarkModelObserver);
1036 }; 1037 };
1037 1038
1038 // Allows the automation provider to wait for all downloads to finish.
1039 // If any download is interrupted, it will cancel all the other downloads at
1040 // the next |OnDownloadUpdated|, and send an error when all are done.
1041 class AutomationProviderDownloadItemObserver : public DownloadItem::Observer {
1042 public:
1043 AutomationProviderDownloadItemObserver(
1044 AutomationProvider* provider,
1045 IPC::Message* reply_message,
1046 int downloads);
1047 virtual ~AutomationProviderDownloadItemObserver();
1048
1049 virtual void OnDownloadUpdated(DownloadItem* download);
1050 virtual void OnDownloadOpened(DownloadItem* download);
1051
1052 private:
1053 void RemoveAndCleanupOnLastEntry(DownloadItem* download);
1054
1055 base::WeakPtr<AutomationProvider> provider_;
1056 scoped_ptr<IPC::Message> reply_message_;
1057 int downloads_;
1058 bool interrupted_;
1059
1060 DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadItemObserver);
1061 };
1062
1063 // Allows the automation provider to wait until the download has been updated 1039 // Allows the automation provider to wait until the download has been updated
1064 // or opened. 1040 // or opened.
1065 class AutomationProviderDownloadUpdatedObserver 1041 class AutomationProviderDownloadUpdatedObserver
1066 : public DownloadItem::Observer { 1042 : public DownloadItem::Observer {
1067 public: 1043 public:
1068 AutomationProviderDownloadUpdatedObserver( 1044 AutomationProviderDownloadUpdatedObserver(
1069 AutomationProvider* provider, 1045 AutomationProvider* provider,
1070 IPC::Message* reply_message, 1046 IPC::Message* reply_message,
1071 bool wait_for_open); 1047 bool wait_for_open);
1072 virtual ~AutomationProviderDownloadUpdatedObserver(); 1048 virtual ~AutomationProviderDownloadUpdatedObserver();
(...skipping 23 matching lines...) Expand all
1096 virtual void ModelChanged(); 1072 virtual void ModelChanged();
1097 1073
1098 private: 1074 private:
1099 base::WeakPtr<AutomationProvider> provider_; 1075 base::WeakPtr<AutomationProvider> provider_;
1100 scoped_ptr<IPC::Message> reply_message_; 1076 scoped_ptr<IPC::Message> reply_message_;
1101 DownloadManager* download_manager_; 1077 DownloadManager* download_manager_;
1102 1078
1103 DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadModelChangedObserver); 1079 DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadModelChangedObserver);
1104 }; 1080 };
1105 1081
1082 // Observes when all pending downloads have completed.
1083 class AllDownloadsCompleteObserver
1084 : public DownloadManager::Observer,
1085 public DownloadItem::Observer {
1086 public:
1087 AllDownloadsCompleteObserver(
1088 AutomationProvider* provider,
1089 IPC::Message* reply_message,
1090 DownloadManager* download_manager,
1091 ListValue* pre_download_ids);
1092 virtual ~AllDownloadsCompleteObserver();
1093
1094 // DownloadManager::Observer.
1095 virtual void ModelChanged();
1096
1097 // DownloadItem::Observer.
1098 virtual void OnDownloadUpdated(DownloadItem* download);
1099 virtual void OnDownloadOpened(DownloadItem* download) {}
1100
1101 private:
1102 void ReplyIfNecessary();
1103
1104 base::WeakPtr<AutomationProvider> provider_;
1105 scoped_ptr<IPC::Message> reply_message_;
1106 DownloadManager* download_manager_;
1107 std::set<int> pre_download_ids_;
1108 std::set<DownloadItem*> pending_downloads_;
1109
1110 DISALLOW_COPY_AND_ASSIGN(AllDownloadsCompleteObserver);
1111 };
1112
1106 // Allows automation provider to wait until TemplateURLService has loaded 1113 // Allows automation provider to wait until TemplateURLService has loaded
1107 // before looking up/returning search engine info. 1114 // before looking up/returning search engine info.
1108 class AutomationProviderSearchEngineObserver 1115 class AutomationProviderSearchEngineObserver
1109 : public TemplateURLServiceObserver { 1116 : public TemplateURLServiceObserver {
1110 public: 1117 public:
1111 AutomationProviderSearchEngineObserver( 1118 AutomationProviderSearchEngineObserver(
1112 AutomationProvider* provider, 1119 AutomationProvider* provider,
1113 IPC::Message* reply_message); 1120 IPC::Message* reply_message);
1114 virtual ~AutomationProviderSearchEngineObserver(); 1121 virtual ~AutomationProviderSearchEngineObserver();
1115 1122
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 1653
1647 private: 1654 private:
1648 NotificationRegistrar registrar_; 1655 NotificationRegistrar registrar_;
1649 base::WeakPtr<AutomationProvider> automation_; 1656 base::WeakPtr<AutomationProvider> automation_;
1650 scoped_ptr<IPC::Message> reply_message_; 1657 scoped_ptr<IPC::Message> reply_message_;
1651 1658
1652 DISALLOW_COPY_AND_ASSIGN(DragTargetDropAckNotificationObserver); 1659 DISALLOW_COPY_AND_ASSIGN(DragTargetDropAckNotificationObserver);
1653 }; 1660 };
1654 1661
1655 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ 1662 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/automation_provider_observers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698