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

Side by Side Diff: chrome/browser/extensions/extension_downloads_api.cc

Issue 8135017: Refactor downloads into a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated latest rounds of comments from John. Created 9 years, 2 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
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 #include "chrome/browser/extensions/extension_downloads_api.h" 5 #include "chrome/browser/extensions/extension_downloads_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/json/json_writer.h" 15 #include "base/json/json_writer.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/string16.h" 19 #include "base/string16.h"
20 #include "base/string_util.h" 20 #include "base/string_util.h"
21 #include "base/stringprintf.h" 21 #include "base/stringprintf.h"
22 #include "base/values.h" 22 #include "base/values.h"
23 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/download/download_service.h"
25 #include "chrome/browser/download/download_service_factory.h"
24 #include "chrome/browser/download/download_util.h" 26 #include "chrome/browser/download/download_util.h"
25 #include "chrome/browser/extensions/extension_downloads_api_constants.h" 27 #include "chrome/browser/extensions/extension_downloads_api_constants.h"
26 #include "chrome/browser/extensions/extension_event_names.h" 28 #include "chrome/browser/extensions/extension_event_names.h"
27 #include "chrome/browser/extensions/extension_event_router.h" 29 #include "chrome/browser/extensions/extension_event_router.h"
28 #include "chrome/browser/icon_loader.h" 30 #include "chrome/browser/icon_loader.h"
29 #include "chrome/browser/icon_manager.h" 31 #include "chrome/browser/icon_manager.h"
30 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 32 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
31 #include "chrome/browser/ui/browser_list.h" 33 #include "chrome/browser/ui/browser_list.h"
32 #include "content/browser/download/download_file_manager.h" 34 #include "content/browser/download/download_file_manager.h"
33 #include "content/browser/download/download_item.h" 35 #include "content/browser/download/download_item.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // TODO(benjhayden): Implement endTime and fileSize. 409 // TODO(benjhayden): Implement endTime and fileSize.
408 // json->SetInteger(constants::kEndTimeKey, -1); 410 // json->SetInteger(constants::kEndTimeKey, -1);
409 json->SetInteger(constants::kFileSizeKey, item->total_bytes()); 411 json->SetInteger(constants::kFileSizeKey, item->total_bytes());
410 return json; 412 return json;
411 } 413 }
412 } // anonymous namespace 414 } // anonymous namespace
413 415
414 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( 416 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter(
415 Profile* profile) 417 Profile* profile)
416 : profile_(profile), 418 : profile_(profile),
417 manager_(profile ? profile->GetDownloadManager() : NULL) { 419 manager_(
420 profile ?
421 DownloadServiceFactory::GetForProfile(profile)->GetDownloadManager() :
422 NULL) {
418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
419 DCHECK(profile_); 424 DCHECK(profile_);
420 DCHECK(manager_); 425 DCHECK(manager_);
421 manager_->AddObserver(this); 426 manager_->AddObserver(this);
422 } 427 }
423 428
424 ExtensionDownloadsEventRouter::~ExtensionDownloadsEventRouter() { 429 ExtensionDownloadsEventRouter::~ExtensionDownloadsEventRouter() {
425 if (manager_ != NULL) 430 if (manager_ != NULL)
426 manager_->RemoveObserver(this); 431 manager_->RemoveObserver(this);
427 } 432 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 ListValue args; 485 ListValue args;
481 args.Append(arg); 486 args.Append(arg);
482 std::string json_args; 487 std::string json_args;
483 base::JSONWriter::Write(&args, false, &json_args); 488 base::JSONWriter::Write(&args, false, &json_args);
484 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( 489 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
485 event_name, 490 event_name,
486 json_args, 491 json_args,
487 profile_, 492 profile_,
488 GURL()); 493 GURL());
489 } 494 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | chrome/browser/profiles/off_the_record_profile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698