Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: compiled/subscription/DownloadableSubscription.cpp

Issue 29384812: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 1 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Left Patch Set: Fixed method names according to convention Created March 16, 2017, 6:26 p.m.
Right Patch Set: Addressed comments Created April 13, 2017, 1:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « compiled/subscription/DownloadableSubscription.h ('k') | compiled/subscription/Subscription.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
1 #include "DownloadableSubscription.h" 18 #include "DownloadableSubscription.h"
2 19
3 DownloadableSubscription::DownloadableSubscription(const String& id) 20 DownloadableSubscription::DownloadableSubscription(const String& id)
4 : Subscription(Type::DOWNLOADABLE, id), mFixedTitle(false), mLastCheck(0), 21 : Subscription(Type::DOWNLOADABLE, id), mFixedTitle(false), mLastCheck(0),
5 mHardExpiration(0), mSoftExpiration(0), mLastDownload(0), mLastSuccess(0), 22 mHardExpiration(0), mSoftExpiration(0), mLastDownload(0), mLastSuccess(0),
6 mErrorCount(0), mDataRevision(0), mDownloadCount(0) 23 mErrorCount(0), mDataRevision(0), mDownloadCount(0)
7 { 24 {
8 SetTitle(id); 25 SetTitle(id);
9 } 26 }
10 27
11 OwnedString DownloadableSubscription::Serialize() const 28 OwnedString DownloadableSubscription::Serialize() const
12 { 29 {
13 OwnedString result(Subscription::Serialize()); 30 OwnedString result(Subscription::Serialize());
14 char buffer[32];
15 if (mFixedTitle) 31 if (mFixedTitle)
16 result.append(u"fixedTitle=true\n"_str); 32 result.append(u"fixedTitle=true\n"_str);
17 if (!mHomepage.empty()) 33 if (!mHomepage.empty())
18 { 34 {
19 result.append(u"homepage="_str); 35 result.append(u"homepage="_str);
20 result.append(mHomepage); 36 result.append(mHomepage);
21 result.append(u'\n'); 37 result.append(u'\n');
22 } 38 }
23 if (mLastCheck) 39 if (mLastCheck)
24 { 40 {
25 result.append(u"lastCheck="_str); 41 result.append(u"lastCheck="_str);
26 int len = sprintf(buffer, "%.0f", mLastCheck); 42 result.append(mLastCheck);
27 result.append(buffer, len);
28 result.append(u'\n'); 43 result.append(u'\n');
29 } 44 }
30 if (mHardExpiration) 45 if (mHardExpiration)
31 { 46 {
32 result.append(u"expires="_str); 47 result.append(u"expires="_str);
33 int len = sprintf(buffer, "%.0f", mHardExpiration); 48 result.append(mHardExpiration);
34 result.append(buffer, len);
35 result.append(u'\n'); 49 result.append(u'\n');
36 } 50 }
37 if (mSoftExpiration) 51 if (mSoftExpiration)
38 { 52 {
39 result.append(u"softExpiration="_str); 53 result.append(u"softExpiration="_str);
40 int len = sprintf(buffer, "%.0f", mSoftExpiration); 54 result.append(mSoftExpiration);
41 result.append(buffer, len);
42 result.append(u'\n'); 55 result.append(u'\n');
43 } 56 }
44 if (mLastDownload) 57 if (mLastDownload)
45 { 58 {
46 result.append(u"lastDownload="_str); 59 result.append(u"lastDownload="_str);
47 int len = sprintf(buffer, "%.0f", mLastDownload); 60 result.append(mLastDownload);
48 result.append(buffer, len);
49 result.append(u'\n'); 61 result.append(u'\n');
50 } 62 }
51 if (!mDownloadStatus.empty()) 63 if (!mDownloadStatus.empty())
52 { 64 {
53 result.append(u"downloadStatus="_str); 65 result.append(u"downloadStatus="_str);
54 result.append(mDownloadStatus); 66 result.append(mDownloadStatus);
55 result.append(u'\n'); 67 result.append(u'\n');
56 } 68 }
57 if (mLastSuccess) 69 if (mLastSuccess)
58 { 70 {
59 result.append(u"lastSuccess="_str); 71 result.append(u"lastSuccess="_str);
60 int len = sprintf(buffer, "%.0f", mLastSuccess); 72 result.append(mLastSuccess);
61 result.append(buffer, len);
62 result.append(u'\n'); 73 result.append(u'\n');
63 } 74 }
64 if (mErrorCount) 75 if (mErrorCount)
65 { 76 {
66 result.append(u"errors="_str); 77 result.append(u"errors="_str);
67 int len = sprintf(buffer, "%i", mErrorCount); 78 result.append(mErrorCount);
68 result.append(buffer, len);
69 result.append(u'\n'); 79 result.append(u'\n');
70 } 80 }
71 if (mDataRevision) 81 if (mDataRevision)
72 { 82 {
73 result.append(u"version="_str); 83 result.append(u"version="_str);
74 int len = sprintf(buffer, "%.0f", mDataRevision); 84 result.append(mDataRevision);
75 result.append(buffer, len);
76 result.append(u'\n'); 85 result.append(u'\n');
77 } 86 }
78 if (!mRequiredVersion.empty()) 87 if (!mRequiredVersion.empty())
79 { 88 {
80 result.append(u"requiredVersion="_str); 89 result.append(u"requiredVersion="_str);
81 result.append(mRequiredVersion); 90 result.append(mRequiredVersion);
82 result.append(u'\n'); 91 result.append(u'\n');
83 } 92 }
84 if (mDownloadCount) 93 if (mDownloadCount)
85 { 94 {
86 result.append(u"downloadCount="_str); 95 result.append(u"downloadCount="_str);
87 int len = sprintf(buffer, "%i", mDownloadCount); 96 result.append(mDownloadCount);
88 result.append(buffer, len);
89 result.append(u'\n'); 97 result.append(u'\n');
90 } 98 }
91 return result; 99 return result;
92 } 100 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld