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

Side by Side Diff: chrome/browser/download/download_history.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 // DownloadHistory manages persisting DownloadItems to the history service by 5 // DownloadHistory manages persisting DownloadItems to the history service by
6 // observing a single DownloadManager and all its DownloadItems using an 6 // observing a single DownloadManager and all its DownloadItems using an
7 // AllDownloadItemNotifier. 7 // AllDownloadItemNotifier.
8 // 8 //
9 // DownloadHistory decides whether and when to add items to, remove items from, 9 // DownloadHistory decides whether and when to add items to, remove items from,
10 // and update items in the database. DownloadHistory uses DownloadHistoryData to 10 // and update items in the database. DownloadHistory uses DownloadHistoryData to
(...skipping 22 matching lines...) Expand all
33 #include "base/macros.h" 33 #include "base/macros.h"
34 #include "base/metrics/histogram_macros.h" 34 #include "base/metrics/histogram_macros.h"
35 #include "chrome/browser/download/download_crx_util.h" 35 #include "chrome/browser/download/download_crx_util.h"
36 #include "components/history/content/browser/download_constants_utils.h" 36 #include "components/history/content/browser/download_constants_utils.h"
37 #include "components/history/core/browser/download_database.h" 37 #include "components/history/core/browser/download_database.h"
38 #include "components/history/core/browser/download_row.h" 38 #include "components/history/core/browser/download_row.h"
39 #include "components/history/core/browser/history_service.h" 39 #include "components/history/core/browser/history_service.h"
40 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
41 #include "content/public/browser/download_item.h" 41 #include "content/public/browser/download_item.h"
42 #include "content/public/browser/download_manager.h" 42 #include "content/public/browser/download_manager.h"
43 #include "extensions/features/features.h"
43 44
44 #if defined(ENABLE_EXTENSIONS) 45 #if BUILDFLAG(ENABLE_EXTENSIONS)
45 #include "chrome/browser/extensions/api/downloads/downloads_api.h" 46 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
46 #endif 47 #endif
47 48
48 namespace { 49 namespace {
49 50
50 // Per-DownloadItem data. This information does not belong inside DownloadItem, 51 // Per-DownloadItem data. This information does not belong inside DownloadItem,
51 // and keeping maps in DownloadHistory from DownloadItem to this information is 52 // and keeping maps in DownloadHistory from DownloadItem to this information is
52 // error-prone and complicated. Unfortunately, DownloadHistory::removing_*_ and 53 // error-prone and complicated. Unfortunately, DownloadHistory::removing_*_ and
53 // removed_while_adding_ cannot be moved into this class partly because 54 // removed_while_adding_ cannot be moved into this class partly because
54 // DownloadHistoryData is destroyed when DownloadItems are destroyed, and we 55 // DownloadHistoryData is destroyed when DownloadItems are destroyed, and we
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 111
111 DISALLOW_COPY_AND_ASSIGN(DownloadHistoryData); 112 DISALLOW_COPY_AND_ASSIGN(DownloadHistoryData);
112 }; 113 };
113 114
114 const char DownloadHistoryData::kKey[] = 115 const char DownloadHistoryData::kKey[] =
115 "DownloadItem DownloadHistoryData"; 116 "DownloadItem DownloadHistoryData";
116 117
117 history::DownloadRow GetDownloadRow( 118 history::DownloadRow GetDownloadRow(
118 content::DownloadItem* item) { 119 content::DownloadItem* item) {
119 std::string by_ext_id, by_ext_name; 120 std::string by_ext_id, by_ext_name;
120 #if defined(ENABLE_EXTENSIONS) 121 #if BUILDFLAG(ENABLE_EXTENSIONS)
121 extensions::DownloadedByExtension* by_ext = 122 extensions::DownloadedByExtension* by_ext =
122 extensions::DownloadedByExtension::Get(item); 123 extensions::DownloadedByExtension::Get(item);
123 if (by_ext) { 124 if (by_ext) {
124 by_ext_id = by_ext->id(); 125 by_ext_id = by_ext->id();
125 by_ext_name = by_ext->name(); 126 by_ext_name = by_ext->name();
126 } 127 }
127 #endif 128 #endif
128 129
129 return history::DownloadRow( 130 return history::DownloadRow(
130 item->GetFullPath(), item->GetTargetFilePath(), item->GetUrlChain(), 131 item->GetFullPath(), item->GetTargetFilePath(), item->GetUrlChain(),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 it->referrer_url, it->site_url, it->tab_url, it->tab_referrer_url, 269 it->referrer_url, it->site_url, it->tab_url, it->tab_referrer_url,
269 it->mime_type, it->original_mime_type, it->start_time, it->end_time, 270 it->mime_type, it->original_mime_type, it->start_time, it->end_time,
270 it->etag, it->last_modified, it->received_bytes, it->total_bytes, 271 it->etag, it->last_modified, it->received_bytes, it->total_bytes,
271 std::string(), // TODO(asanka): Need to persist and restore hash of 272 std::string(), // TODO(asanka): Need to persist and restore hash of
272 // partial file for an interrupted download. No need to 273 // partial file for an interrupted download. No need to
273 // store hash for a completed file. 274 // store hash for a completed file.
274 history::ToContentDownloadState(it->state), 275 history::ToContentDownloadState(it->state),
275 history::ToContentDownloadDangerType(it->danger_type), 276 history::ToContentDownloadDangerType(it->danger_type),
276 history::ToContentDownloadInterruptReason(it->interrupt_reason), 277 history::ToContentDownloadInterruptReason(it->interrupt_reason),
277 it->opened); 278 it->opened);
278 #if defined(ENABLE_EXTENSIONS) 279 #if BUILDFLAG(ENABLE_EXTENSIONS)
279 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) { 280 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) {
280 new extensions::DownloadedByExtension( 281 new extensions::DownloadedByExtension(
281 item, it->by_ext_id, it->by_ext_name); 282 item, it->by_ext_id, it->by_ext_name);
282 item->UpdateObservers(); 283 item->UpdateObservers();
283 } 284 }
284 #endif 285 #endif
285 DCHECK_EQ(DownloadHistoryData::PERSISTED, 286 DCHECK_EQ(DownloadHistoryData::PERSISTED,
286 DownloadHistoryData::Get(item)->state()); 287 DownloadHistoryData::Get(item)->state());
287 ++history_size_; 288 ++history_size_;
288 } 289 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } 464 }
464 465
465 void DownloadHistory::RemoveDownloadsBatch() { 466 void DownloadHistory::RemoveDownloadsBatch() {
466 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 467 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
467 IdSet remove_ids; 468 IdSet remove_ids;
468 removing_ids_.swap(remove_ids); 469 removing_ids_.swap(remove_ids);
469 history_->RemoveDownloads(remove_ids); 470 history_->RemoveDownloads(remove_ids);
470 for (Observer& observer : observers_) 471 for (Observer& observer : observers_)
471 observer.OnDownloadsRemoved(remove_ids); 472 observer.OnDownloadsRemoved(remove_ids);
472 } 473 }
OLDNEW
« no previous file with comments | « chrome/browser/download/chrome_download_manager_delegate.cc ('k') | chrome/browser/download/download_history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698