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

Side by Side Diff: chrome/browser/dom_ui/downloads_dom_handler.cc

Issue 6461024: Revert 74292 - Splits ChromeURLDataManager into 2 chunks:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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 | « chrome/browser/dom_ui/conflicts_ui.cc ('k') | chrome/browser/dom_ui/downloads_ui.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/browser/dom_ui/downloads_dom_handler.h" 5 #include "chrome/browser/dom_ui/downloads_dom_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/singleton.h" 12 #include "base/singleton.h"
13 #include "base/string_piece.h" 13 #include "base/string_piece.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/browser_thread.h" 18 #include "chrome/browser/browser_thread.h"
19 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" 19 #include "chrome/browser/dom_ui/chrome_url_data_manager.h"
20 #include "chrome/browser/dom_ui/fileicon_source.h" 20 #include "chrome/browser/dom_ui/fileicon_source.h"
21 #include "chrome/browser/download/download_history.h" 21 #include "chrome/browser/download/download_history.h"
22 #include "chrome/browser/download/download_item.h" 22 #include "chrome/browser/download/download_item.h"
23 #include "chrome/browser/download/download_util.h" 23 #include "chrome/browser/download/download_util.h"
24 #include "chrome/browser/metrics/user_metrics.h" 24 #include "chrome/browser/metrics/user_metrics.h"
25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/tab_contents/tab_contents.h" 25 #include "chrome/browser/tab_contents/tab_contents.h"
27 #include "chrome/common/jstemplate_builder.h" 26 #include "chrome/common/jstemplate_builder.h"
28 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
29 #include "grit/browser_resources.h" 28 #include "grit/browser_resources.h"
30 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
31 30
32 namespace { 31 namespace {
33 32
34 // Maximum number of downloads to show. TODO(glen): Remove this and instead 33 // Maximum number of downloads to show. TODO(glen): Remove this and instead
35 // stuff the downloads down the pipe slowly. 34 // stuff the downloads down the pipe slowly.
36 static const int kMaxDownloads = 150; 35 static const int kMaxDownloads = 150;
37 36
38 // Sort DownloadItems into descending order by their start time. 37 // Sort DownloadItems into descending order by their start time.
39 class DownloadItemSorter : public std::binary_function<DownloadItem*, 38 class DownloadItemSorter : public std::binary_function<DownloadItem*,
40 DownloadItem*, 39 DownloadItem*,
41 bool> { 40 bool> {
42 public: 41 public:
43 bool operator()(const DownloadItem* lhs, const DownloadItem* rhs) { 42 bool operator()(const DownloadItem* lhs, const DownloadItem* rhs) {
44 return lhs->start_time() > rhs->start_time(); 43 return lhs->start_time() > rhs->start_time();
45 } 44 }
46 }; 45 };
47 46
48 } // namespace 47 } // namespace
49 48
50 DownloadsDOMHandler::DownloadsDOMHandler(DownloadManager* dlm) 49 DownloadsDOMHandler::DownloadsDOMHandler(DownloadManager* dlm)
51 : search_text_(), 50 : search_text_(),
52 download_manager_(dlm), 51 download_manager_(dlm),
53 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 52 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
54 // Create our fileicon data source. 53 // Create our fileicon data source.
55 dlm->profile()->GetChromeURLDataManager()->AddDataSource( 54 BrowserThread::PostTask(
56 new FileIconSource()); 55 BrowserThread::IO, FROM_HERE,
56 NewRunnableMethod(
57 ChromeURLDataManager::GetInstance(),
58 &ChromeURLDataManager::AddDataSource,
59 make_scoped_refptr(new FileIconSource())));
57 } 60 }
58 61
59 DownloadsDOMHandler::~DownloadsDOMHandler() { 62 DownloadsDOMHandler::~DownloadsDOMHandler() {
60 ClearDownloadItems(); 63 ClearDownloadItems();
61 download_manager_->RemoveObserver(this); 64 download_manager_->RemoveObserver(this);
62 } 65 }
63 66
64 // DownloadsDOMHandler, public: ----------------------------------------------- 67 // DownloadsDOMHandler, public: -----------------------------------------------
65 68
66 void DownloadsDOMHandler::Init() { 69 void DownloadsDOMHandler::Init() {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return NULL; 243 return NULL;
241 } 244 }
242 245
243 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { 246 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) {
244 int id; 247 int id;
245 if (ExtractIntegerValue(args, &id)) { 248 if (ExtractIntegerValue(args, &id)) {
246 return GetDownloadById(id); 249 return GetDownloadById(id);
247 } 250 }
248 return NULL; 251 return NULL;
249 } 252 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/conflicts_ui.cc ('k') | chrome/browser/dom_ui/downloads_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698