OLD | NEW |
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 // Portions of this code based on Mozilla: | 5 // Portions of this code based on Mozilla: |
6 // (netwerk/cookie/src/nsCookieService.cpp) | 6 // (netwerk/cookie/src/nsCookieService.cpp) |
7 /* ***** BEGIN LICENSE BLOCK ***** | 7 /* ***** BEGIN LICENSE BLOCK ***** |
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
9 * | 9 * |
10 * The contents of this file are subject to the Mozilla Public License Version | 10 * The contents of this file are subject to the Mozilla Public License Version |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 public: | 545 public: |
546 DeleteTask(CookieMonster* cookie_monster, | 546 DeleteTask(CookieMonster* cookie_monster, |
547 const typename CallbackType<Result>::Type& callback) | 547 const typename CallbackType<Result>::Type& callback) |
548 : CookieMonsterTask(cookie_monster), | 548 : CookieMonsterTask(cookie_monster), |
549 callback_(callback) { | 549 callback_(callback) { |
550 } | 550 } |
551 | 551 |
552 // CookieMonsterTask: | 552 // CookieMonsterTask: |
553 virtual void Run() override; | 553 virtual void Run() override; |
554 | 554 |
| 555 protected: |
| 556 ~DeleteTask() override; |
| 557 |
555 private: | 558 private: |
556 // Runs the delete task and returns a result. | 559 // Runs the delete task and returns a result. |
557 virtual Result RunDeleteTask() = 0; | 560 virtual Result RunDeleteTask() = 0; |
558 base::Closure RunDeleteTaskAndBindCallback(); | 561 base::Closure RunDeleteTaskAndBindCallback(); |
559 void FlushDone(const base::Closure& callback); | 562 void FlushDone(const base::Closure& callback); |
560 | 563 |
561 typename CallbackType<Result>::Type callback_; | 564 typename CallbackType<Result>::Type callback_; |
562 | 565 |
563 DISALLOW_COPY_AND_ASSIGN(DeleteTask); | 566 DISALLOW_COPY_AND_ASSIGN(DeleteTask); |
564 }; | 567 }; |
565 | 568 |
566 template <typename Result> | 569 template <typename Result> |
567 base::Closure CookieMonster::DeleteTask<Result>:: | 570 CookieMonster::DeleteTask<Result>::~DeleteTask() { |
568 RunDeleteTaskAndBindCallback() { | 571 } |
| 572 |
| 573 template <typename Result> |
| 574 base::Closure |
| 575 CookieMonster::DeleteTask<Result>::RunDeleteTaskAndBindCallback() { |
569 Result result = RunDeleteTask(); | 576 Result result = RunDeleteTask(); |
570 if (callback_.is_null()) | 577 if (callback_.is_null()) |
571 return base::Closure(); | 578 return base::Closure(); |
572 return base::Bind(callback_, result); | 579 return base::Bind(callback_, result); |
573 } | 580 } |
574 | 581 |
575 template <> | 582 template <> |
576 base::Closure CookieMonster::DeleteTask<void>::RunDeleteTaskAndBindCallback() { | 583 base::Closure CookieMonster::DeleteTask<void>::RunDeleteTaskAndBindCallback() { |
577 RunDeleteTask(); | 584 RunDeleteTask(); |
578 return callback_; | 585 return callback_; |
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2334 it != hook_map_.end(); ++it) { | 2341 it != hook_map_.end(); ++it) { |
2335 std::pair<GURL, std::string> key = it->first; | 2342 std::pair<GURL, std::string> key = it->first; |
2336 if (cookie.IncludeForRequestURL(key.first, opts) && | 2343 if (cookie.IncludeForRequestURL(key.first, opts) && |
2337 cookie.Name() == key.second) { | 2344 cookie.Name() == key.second) { |
2338 it->second->Notify(cookie, removed); | 2345 it->second->Notify(cookie, removed); |
2339 } | 2346 } |
2340 } | 2347 } |
2341 } | 2348 } |
2342 | 2349 |
2343 } // namespace net | 2350 } // namespace net |
OLD | NEW |