Last Comment Bug 687755 - Make it easy to forward methods from the DOM storage wrapper to the right implementation class
: Make it easy to forward methods from the DOM storage wrapper to the right imp...
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: DOM (show other bugs)
: unspecified
: x86 Mac OS X
: -- normal (vote)
: mozilla9
Assigned To: Boris Zbarsky [:bz]
:
Mentors:
Depends on:
Blocks: 683316 686049
  Show dependency treegraph
 
Reported: 2011-09-19 19:49 PDT by Boris Zbarsky [:bz]
Modified: 2013-04-04 13:53 PDT (History)
3 users (show)
bzbarsky: in‑testsuite-
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Refactor some code to make it easier to add new nsDOMStorageDBWrapper methods that forward to the various storage implementations. (7.18 KB, patch)
2011-09-19 19:50 PDT, Boris Zbarsky [:bz]
no flags Details | Diff | Review

Description Boris Zbarsky [:bz] 2011-09-19 19:49:01 PDT
This is a spinoff bug to track landing the first (already reviewed) patch in bug 686049.
Comment 1 Boris Zbarsky [:bz] 2011-09-19 19:50:00 PDT
Created attachment 561105 [details] [diff] [review]
Refactor some code to make it easier to add new nsDOMStorageDBWrapper methods that forward to the various storage implementations.
Comment 3 Honza Bambas (:mayhemer) 2011-09-20 03:52:44 PDT
According bug 683316 comment 4, could we update this to also support methods that has |void| return type somehow?

Maybe:

+#define IMPL_FORWARDER(_return, _code)                                \
+  PR_BEGIN_MACRO                                                      \
+  if (aStorage->CanUseChromePersist())                                \
+    _return mChromePersistentDB._code;                                \
+  if (nsDOMStorageManager::gStorageManager->InPrivateBrowsingMode())  \
+    _return mPrivateBrowsingDB._code;                                 \
+  if (aStorage->SessionOnly())                                        \
+    _return mSessionOnlyDB._code;                                     \
+  _return mPersistentDB._code;                                        \
+  PR_END_MACRO
+

And then:

 nsresult
 nsDOMStorageDBWrapper::GetAllKeys(DOMStorageImpl* aStorage,
                                   nsTHashtable<nsSessionStorageEntry>* aKeys)
 {
   IMPL_FORWARDER(return, GetAllKeys(aStorage, aKeys));
 }

 void
 nsDOMStorageDBWrapper::Whatever(...)
 {
   IMPL_FORWARDER((void), Whatever(...));
 }
Comment 4 :Ehsan Akhgari (busy, don't ask for review please) 2011-09-20 07:48:59 PDT
https://hg.mozilla.org/mozilla-central/rev/30a5dfdf8aba
Comment 5 Boris Zbarsky [:bz] 2011-09-20 09:26:26 PDT
I was assuming you'd add a macro for that in bug 683316.  I'd prefer a IMPL_FORWARDER_GUTS macro with two arguments and an IMPL_FORWARDER and IMPL_VOID_FORWARDER that invoke it the right way.

Note You need to log in before you can comment on or make changes to this bug.